I have a very simple LSTM model defined as
def get_lstm_model(shape_input, num_output):
model = Sequential([
layers.Input((shape_input, num_output)),
layers.LSTM(64),
layers.Dense(32, activation = 'relu'),
])
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics = ['accuracy'])
return model
The model definition works fine with the below lines
model_mlp = get_lstm_model(8,5)
model_mlp.summary()
Now when I am fitting the model, I get the error in response to this line
model_history = model_mlp.fit(x_train, y_train, validation_split=0.2,
epochs=500, batch_size=5000)
The error I get is:
"Input 0 of layer "lstm_3" is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 8)"
For clarity, the shape of x_train is (2134,8), while the shape of y_train is (2134,5)
Any help would be greatly appreciated.