I have read a sequence of images into a numpy array with shape (7338, 225, 1024, 3)
where 7338
is the sample size, 225
are the time steps and 1024 (32x32)
are flattened image pixels, in 3
channels (RGB).
I have a sequential model with an LSTM layer:
model = Sequential()
model.add(LSTM(128, input_shape=(225, 1024, 3))
But this results in the error:
Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=4
The documentation mentions that the input tensor for LSTM layer should be a 3D tensor with shape (batch_size, timesteps, input_dim)
, but in my case my input_dim
is 2D.
What is the suggested way to input a 3 channel image into an LSTM layer in Keras?
X_train.shape[1:]
gives me(225, 1024, 3)
which is what was hard-coded as theinput_shape
param – Sonni