Keras阵列输入错误 [英] Keras Array Input Error
本文介绍了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 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模型中.
in my keras model.
我认为该模型有误入歧途吗?
I think the model is mistaking something?
当我将输入输入模型时会发生这种情况.相同的输入在另一个程序中可以很好地工作.
This happens when I feed input to my model. The same input works perfectly well in another program.
推荐答案
没有更多信息就无法诊断出确切的问题.
It's impossible to diagnose your exact problem without more information.
我通常根据我的训练数据X
指定第一层的input_shape
参数.
I usually specify the input_shape
parameter of the first layer based on my training data X
.
例如
model = Sequential()
model.add(Dense(32, input_shape=X.shape[0]))
我想您希望X
看起来像这样:
I think you'll want X
to look something like this:
[
[[ 0, 0, 0, ..., 18, 11, 1]],
[[ 0, 0, 0, ..., 18, 9, 1]],
....
]
因此,您可以尝试使用以下行来重塑它:
So you could try reshaping it with the following line:
X = np.array([[sample] for sample in X])
这篇关于Keras阵列输入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文