我创建了以下网络。这个想法是结合 和 的输出left
,right
然后发送到 LSTM 模型。
EMBED_DIM = 4
look_back = 6
feature_num = 2
ENCODE_DIM = 676
left = Sequential()
left.add(Dense(EMBED_DIM,input_shape=(ENCODE_DIM,)))
left.add(RepeatVector(look_back))
left.add(Reshape((look_back,EMBED_DIM)))
right = Sequential()
right.add(Lambda(lambda x: x,input_shape=(look_back,feature_num)))
# create and fit the LSTM network
model = Sequential()
model.add(Concatenate([left, right], axis = 2,input_shape=(look_back, EMBED_DIM + feature_num) ))
model.add(LSTM(8, input_shape=(look_back,feature_num + EMBED_DIM)))
model.add(Dense(2))
model.compile(loss='mean_squared_error', optimizer='adam')
我试图连接左右输出,然后将新张量发送到 LSTM 模型。
但是,我收到以下错误:
TypeError Traceback (most recent call last)
<ipython-input-156-275f5597cdad> in <module>()
---> 37 model.add(Concatenate([left, right], axis = 2,input_shape=(look_back, EMBED_DIM + feature_num) ))
38 model.add(LSTM(8, input_shape=(look_back,feature_num + EMBED_DIM)))
39
TypeError: __init__() got multiple values for argument 'axis'
知道我做错了什么吗?我可以添加一个Concatenate
图层作为模型的第一层吗?谢谢!