gpt4 book ai didi

python - Keras: ValueError: Input 0 is incompatible layer 问题

转载 作者:可可西里 更新时间:2023-11-01 11:52:03 26 4
gpt4 key购买 nike

<分区>

我将 Keras 与 Tensorflow 一起用作后端并出现不兼容的错误:

model = Sequential()
model.add(LSTM(64, input_dim = 1))
model.add(Dropout(0.2))
model.add(LSTM(16))

出现如下错误:

Traceback (most recent call last):
File "train_lstm_model.py", line 36, in <module>
model.add(LSTM(16))
File "/home/***/anaconda2/lib/python2.7/site-packages/keras/models.py", line 332, in add
output_tensor = layer(self.outputs[0])
File "/home/***/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 529, in __call__
self.assert_input_compatibility(x)
File "/home/***/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 469, in assert_input_compatibility
str(K.ndim(x)))
ValueError: Input 0 is incompatible with layer lstm_2: expected ndim=3, found ndim=2

我该如何解决这个问题?

凯拉斯版本:1.2.2 tensorflow 版本:0.12

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com