1 回答
TA贡献2021条经验 获得超8个赞
你真的应该升级到 Keras 2;在 Keras 1.x 中,units甚至不是一个有效的参数,因此你的错误:
import keras
from keras.models import Sequential
from keras.layers import LSTM
keras.__version__
# '2.2.4'
您的情况在 Keras 2 中仍然出现错误,尽管有所不同:
model = Sequential()
model.add(LSTM(units=64, input_shape=(77, 1), output_dim=1))
[...]
TypeError: For the `units` argument, the layer received both the legacy keyword argument `output_dim` and the Keras 2 keyword argument `units`. Stick to the latter!
省略遗留output_dim参数,正如消息所建议的那样,我们让它工作:
model = Sequential()
model.add(LSTM(units=64, input_shape=(77, 1)))
model.summary()
# result:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
lstm_1 (LSTM) (None, 64) 16896
=================================================================
Total params: 16,896
Trainable params: 16,896
Non-trainable params: 0
_________________________________________________________________
所以,我真的建议你升级到 Keras 2(我非常怀疑 Keras 1.x 与 Tensorflow 1.2 兼容),如果你仍然有问题,请打开一个新问题......
添加回答
举报