1

我有以下代码:

max_features = 5000
maxlen = 140
model = Sequential()

model.add(Embedding(max_features, 128)) 
model.add(LSTM(128, activation = 'sigmoid', inner_activation =  'hard_sigmoid', return_sequences = False))
model.add(Dense(input_dim = 128, output_dim = 2, activation = 'softmax'))

optimizer = Adam(lr = 0.001, beta_1 = 0.9, beta_2 = 0.999, epsilon = 1e-8)
model.compile(loss = 'categorical_crossentropy', optimizer = optimizer)

model.fit(x_train, y_train, batch_size = 64, nb_epoch = 10, verbose = 2)

y_test_pred = model.predict_classes(x_test)

但是每次我运行它时,我都会在该行出现错误

model.compile(loss = 'categorical_crossentropy', optimizer = optimizer)

其中指出:

 AssertionError: The number of inputs given to the inner function of scan does not match the number of inputs given to scan.

有谁知道那是什么意思?

4

1 回答 1

0

OP的回答:

我已经解决了这个问题,结果发现它与过时的 Theano 版本有关。因此,如果您遇到此问题,请更新您的 theano 模块!

于 2018-05-04T09:39:48.900 回答