'Keras: Input 0 of layer "lstm" is incompatible with the layer: expected ndim=3, found ndim=2
I'm making a paraphrase detection model. My current model is as follows:
left_input = Input(shape=(120, ))
right_input = Input(shape=(120, ))
left_embedding = Embedding(vocab_size, 120, input_length=max_length)(left_input)
right_embedding = Embedding(vocab_size, 120, input_length=max_length)(right_input)
left_lstm = LSTM(120, )(left_embedding)
right_lstm = LSTM(120, )(right_embedding)
concat = concatenate([left_lstm, right_lstm], name='Concatenate')
model_output = Dense(2, activation='softmax')(concat)
model = Model(inputs=[left_embedding, right_embedding], outputs=model_output, name='Final_output')
model.compile(optimizer='adam', loss='binary_crossentropy')
But when I try to fit, it throws an error:
model.fit(x=[train_sentences_1, train_sentences_2], y=train_labels,
validation_data=([val_sentences_1, val_sentences_2], val_labels),
epochs = 10, batch_size = 32)
Input 0 of layer "lstm" is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 120).
train_sentences_1, train_sentences_2 are of shape (10000, 120) while train_labels is of shape (10000, 1)
Can someone help me in fixing the problem? I understand its complaining about dimensionality error in LSTM error but I'm not sure how it can be fixed.
Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
