I'm trying to train LSTM model in Keras using data of variable timestep, for example, the data looks like:
x1 : [[0,0], [0,0], [0,0]]
x2 : [[0,0], [0,0]]
x3 : [[0,0], [0,0], [0,0], [0,0]]
x1's timestep is 3, x2's timestep is 2 and x3's timestep is 4
Here is the definition of lstm layer:
model.add(LSTM(256, input_shape=(None, 2), return_sequences=True))
I can train this model using
model.fit(x1, y1)
model.fit(x2, y2)
model.fit(x3, y3)
It works fine. but in this way, only 1 data can be used to train the model.
Because x1, x2 and x3 has different shape, I can't stack them to a numpy array like:
np.hstack((x1, x2, x3))
So do I have to train the model using data one by one? Is there some way to train this model in batch? Thank you all for helping me with it :)