首页 > 解决方案 > TypeError: call() 得到了一个意外的关键字参数“input_shape”

问题描述

我正在实现一个 LSTM,我的火车数据的形状是 (5237162, 99, 1)。

我按如下方式创建模型,但遇到错误。

TypeError: call() got an unexpected keyword argument 'input_shape'

我尝试从 github 将 Keras 升级到最新版本。不工作。

LSTM_model = Sequential()
LSTM_model.add(LSTM(256,input_shape=(final_ip.shape[1],final_ip.shape[2])))

有人可以帮我解决这个问题吗?

标签: pythonkeraslstm

解决方案


这很奇怪!在我的笔记本中运行您的代码运行良好。我注意到'input_shape'不是官方keras上显示的LSTM层的参数

可能是版本问题!

我的版本:keras '2.2.4',tensorflow '1.11.0'

要绕过它,您可以尝试功能 api:

from keras.layers import Input
input1 = Input(shape =( final_ip.shape[1],final_ip.shape[2] ) )
x = LSTM(256)(input1)

model = Model(input1,x)         

推荐阅读