'The added layer must be an instance of class Layer

I am merging two embding layers for two LSTM models as follows: Code here in this image

When I was building the sequential model, it gave me an error.

model = Sequential()
merged = Concatenate(axis=1)([s1rnn.output,s2rnn.output])
model.add(merged)
model.add(Dense(1))
model.compile(loss='categorical_crossentropy', optimizer='adam',  metrics=['accuracy'])
model.fit([X1,X2], Y,batch_size=128, nb_epoch=20, validation_split=0.05)

TypeError: The added layer must be an instance of class Layer. Received: layer=KerasTensor(type_spec=TensorSpec(shape=(None, 110, 1), dtype=tf.float32, name=None), name='concatenate/concat:0', description="created by layer 'concatenate'") of type <class 'keras.engine.keras_tensor.KerasTensor'>.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source