In building LSTM, we are required to provide input shape information by:
input_shape = () # a tuple
alternatively, by:
input_length = () # an integer
input_dim = () # an integer
I feel a little confused about the two quantities. What are they indicating?
Also, is the input_dim the so-called time steps?
I will try to simplify the input shape parameters as much as possible: In case of LSTM (or in general for RNNs) the input shape can be provided either by:
input_shape key word argument: input_shape = (input_length, input_dim)
where input_length = length of sequence and input_dim = number of features/variables. If the values are not supplied, it indicates any positive integer can be expected. Here you do not mention the batch size i.e. number of observations for updates in weights during training. e.g
input_length = 50 (this is your sequence length)
input_dim = 10 (this is your number of input features in the data)
model.add(LSTM(16, input_shape = (50,10)))
using separate input_dim and input_length arguments
Here you specify input_dim i.e. number of features in the data and input_length i.e. sequence length of single observation in your data separately. for e.g.
model.add(LSTM(16, input_length= 50, input_dim =10))
. This is equivalent to the way described above
Lastly, you can specify the size of batch (which has not been specified above) through batch_input_size argument.if the LSTM is stateful you have to pre-specify the batch size. batch_input_size = (batch_size,input_length, input_dim)
model.add(LSTM(16,batch_input_size = (None,50,10)))
equivalent to the above two
model.add(LSTM(16,batch_input_size = (32,50,10)))
the batch size is 32
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With