为什么仅更改输出激活层会得到空输出?

时间:2019-02-26 22:44:23

标签: python keras

它像这样正常工作:

def make_model(layers, neurons):
    model = Sequential()
    model.add(Dense(neurons, input_dim=15, activation='sigmoid'))
    for l in range(layers - 2):
        model.add(Dense(neurons, activation='sigmoid'))
    model.add(Dense(14, activation='sigmoid'))
    model.compile(loss='mae', optimizer='adam', metrics=['categorical_accuracy'])
    return model

但它会像这样中断(请参阅输出激活)

def make_model(layers, neurons):
    model = Sequential()
    model.add(Dense(neurons, input_dim=15, activation='sigmoid'))
    for l in range(layers - 2):
        model.add(Dense(neurons, activation='sigmoid'))
    model.add(Dense(14, activation='linear'))
    model.compile(loss='mae', optimizer='adam', metrics=['categorical_accuracy'])
    return model

出现此错误:

 File "C:\Users\birdm\OneDrive\Desktop\ai\mancala\libs\generate_train_batch.py", line 82, in play_one_game
    history[whos_turn]['before'].append(targets[choice])
TypeError: list indices must be integers or slices, not NoneType

为什么我只通过更改输出激活层而得到空输出?

0 个答案:

没有答案