![](/img/trans.png)
[英]Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected
[英]The list of Numpy arrays that you are passing to your model is not the size the model expected on 3d arrays
我正在学习使用keras
的Sequential
构建神经网络,但是运行此命令时出现错误:
X = [
[[1,4,5],[7,8,15],[13,16,45],[19,32,135]],
[[0,0,0],[1,4,9], [16,25,36],[49,64,82]],
[[1,1,1], [2,2,2], [1,1,1], [2,2,2]]
]
y = [
[[25,64,405], [31,128,1215]],
[[100,121,144], [169,196, 225]],
[[1,1,1],[2,2,2]]
]
X= np.array(X)
Y= np.array(y)
model = keras.models.Sequential()
model.add(LSTM(16, activation='relu', input_shape=(4, 3)))
model.add(Dense(32, activation='relu'))
model.add(Dense(3))
model.compile(loss='mse', optimizer='adam')
# fit network
model.fit(X, y, epochs=10, batch_size=4)
return model
Error when checking model target: 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 3 arrays:
我认为 Sequential 应该采用 3d 数组,我在其中指定了timesteps=4
和features=3
的数量,但看起来我的格式不正确。 谁能告诉我我做错了什么?
首先,您将 model 安装到y和到Y 。 其次,Y 应该是一个 (None, 3) 数组,因为您的网络输出 3 个值,但 Y 是 (None, 2, 3)。
从纠正这些错误开始,然后看看是否有问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.