1

I'm having some difficulty grasping the input_shape for an LSTM layer in Keras. Assume that is the first layer in the network; it takes input of the form (batch, time, features). Also assume there is only one feature, so the input is of the form (batch, time, 1).

Is the number "batch" the batch size or the number of batches? I assume it's the batch size from the examples I've seen online. Then I'm struggling to see how the number of batches isn't always one.

As a concrete example, I have a time series of 1000 steps, which I split to 10 series of 100 steps. One epoch is when the network goes through all 1000 steps, the 10 series. I should be free to split the 10 series into different batches with different batch sizes, but then the input would be of the form (number of batches, batch size, time steps, 1). What am I misunderstanding?

1
  • Consider you have 1000 examples with just one feature and you want to use previous 10 values as as 'lookback steps', then you will feed your input (x) having the shape (1000,10,1). If your batch size is 32, then keras will take (32,10,1) from your x as one batch for training and it will take 32 batches to make one epoch (considering validation data is not taken from these 1000 examples). Commented Dec 17, 2020 at 9:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.