I am working with some data that contains some features in some continues days and the shape of the array of each of these data is as below:
(number of days, 1, number of features)
Number of features in each of these data is different.
I want to feed each of these data, separately to my lstm model. So I want to implement my model in a way that its input shape is dynamic.
I have used this code:
model = Sequential()
model.add(LSTM(4, return_sequences=True, input_shape=(1, None)))
model.add(LSTM(256, dropout=0.2,recurrent_dropout=0.2, return_sequences=True))
model.add(LSTM(256, dropout=0.2,recurrent_dropout=0.2, return_sequences=True))
model.add(LSTM(128, dropout=0.2,recurrent_dropout=0.2, return_sequences=True))
model.add(LSTM(128))
model.add(Dense(1, activation='sigmoid'))
model.compile (
loss='mean_squared_error',
optimizer=keras.optimizers.Adam(0.001)
)
That None in the first layer is for number of features. But I get this error for this layer when I start to fit the model on (X_train and y_train):
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
I am using tensorflow version '2.3.0-tf'
Can you help me to fix this error?