我收到以下错误:
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]],
....
]
所以你可以尝试使用以下行 reshape 它:
X = np.array([[sample] for sample in X])
关于numpy - Keras 数组输入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41248677/