我遇到了以下错误:
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 6 arrays but instead got the following list of 3 arrays: [array([[ 0, 0, 0, ..., 18, 12, 1], [ 0, 0, 0, ..., 18, 11, 1], [ 0, 0, 0, ..., 18, 9, 1], ..., [ 0, 0, 0, ..., 18, 15, 1], [ 0, 0, 0, ..., 18, 9, ...
在我的Keras模型中出现了这个问题。
我认为模型可能误解了某些东西?
当我向模型输入数据时就会发生这种情况。相同的输入在另一个程序中运行得很好。
回答:
没有更多信息的情况下,无法诊断您的确切问题。
我通常会根据我的训练数据X
来指定第一层的input_shape
参数。
例如:
model = Sequential()model.add(Dense(32, input_shape=X.shape[0]))
我想您希望X
看起来像这样:
[ [[ 0, 0, 0, ..., 18, 11, 1]], [[ 0, 0, 0, ..., 18, 9, 1]], .... ]
所以您可以尝试使用以下代码重塑它:
X = np.array([[sample] for sample in X])