Keras模型传递给模型的Numpy数组列表不是模型期望的大小

时间:2019-01-16 18:58:46

标签: python-3.x machine-learning keras

我对keras模型有疑问。 我收到此错误:

ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 165757 arrays: [array([[0],
   [1]]), array([[2],
   [3]]), array([[4],
   [5]]), array([[6],
   [7]]), array([[8],
   [9]]), array([[10],
   [11]]), array([[12],
   [13]]), array([[14],

...

在训练部分中有误:

model.fit (X_train, y_train,
       batch_size=64,
       epochs=7,
       validation_data=(X_dev, y_dev),
       verbose=1)
scores = model.evaluate(X_test, y_test, batch_size=64)
print("Accuracy is: %.2f%%" %(scores[1] * 100))   

问题出在X_train中。作为数据,我有成对的单词,这些单词可能彼此无关。我代表id的单词:

[[0, 1],
 [2, 3],
 [4, 5],
 [4, 6],
 [7, 8]]

根据错误的模型希望数据为一个列表。问题是,我需要通过配对。有人知道在这种情况下该怎么做吗?

0 个答案:

没有答案