Reputation: 287
I'm trying to merge two LSTM layers together, to no success.
answers_questions_lstm = LSTM(256,input_shape=(8,4,))
answers_contexts_lstm = LSTM(256,input_shape=(10,6,))
answers_combined_lstm = Add()([answers_questions_lstm,answers_contexts_lstm])
answers_hidden_1 = Dense(124)(answers_combined_lstm)
answers_output = Dense(outputTrain.shape[1])
answers_network_1.summary()
This gives me "A merge layer should be called on a list of inputs." Why?
Upvotes: 0
Views: 148
Reputation: 4745
Since you are using the Keras Functional API, you should start with some Input layers. Then call your LSTM layers on the Inputs to get tensor outputs that can then be passed to the Add layer:
answers_questions_input = Input(shape=(8,4))
answers_contexts_input = Input(shape=(10,6))
answers_questions_lstm = LSTM(256)(answers_questions_input)
answers_contexts_lstm = LSTM(256)(answers_contexts_input)
answers_combined_lstm = Add()([answers_questions_lstm, answers_contexts_lstm])
answers_hidden_1 = Dense(124)(answers_combined_lstm)
answers_output = Dense(outputTrain.shape[1])
answers_network_1 = Model(inputs=[answers_questions_input, answers_contexts_input], outputs=answers_output)
answers_network_1.summary()
Upvotes: 3