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 兼容),如果你仍然有問題,請打開一個新問題......
添加回答
舉報
