boswell percy
boswell percy

Reputation: 41

Keras error: Input 0 is incompatible with layer lstm_10: expected ndim=3, found ndim=2

please bear with me i'm quite new to SO.

I'm training a classifier using LSTM and have the below code

I'm having a problem where the 3rd LSTM layer is saying that there is a problem with the dimensionality

My training set has shape (34799, 32, 32)

model = Sequential()
model.add(LSTM(64, activation = 'relu', input_shape=X_train[0].shape, return_sequences=True))
model.add(Dropout(0.25))
model.add(LSTM(128, activation = 'relu'))
model.add(Dropout(0.25))
model.add(LSTM(128, activation = 'relu'))
model.add(Dropout(0.25))
model.add(LSTM(64, activation = 'relu'))
model.add(Dropout(0.25))
model.add(Dense(len(sign_names), activation='softmax'))

Upvotes: 1

Views: 368

Answers (1)

Victor Sim
Victor Sim

Reputation: 368

Return sequences for each LSTM layer should do the trick.

Upvotes: 2

Related Questions