0
votes

I'm trying to understand input arguments of keras for LSTM implementation. I went through keras document and some tutorials to crystalize my knowledge.

enter image description here

Given a time series data in the figure. Suppose we would like to use price of 5 previous days to predict the price of 3 coming days. I define the arguments as follows

  • sample: Each sequence in window (t-5, t-4, ... , t-1)
  • label: (t, t + 1, t+2) but I still confuse about how to organize it in numpy array
  • observation: each day price in sample. So, from my example, we have 5 observations in a single sample
  • timestep: the number of steps for sliding window.
    • Slide window every day means timestep = 1.
    • Slide window every two days means timestep = 2.
  • feature: The number of time series data. My example has only one feature (Price)
  • Batch size: 1 represents stochastic gradient descent. N represents batch training. 1 <= batch_size <= N represents mini-batch training.
  • look_back: This one I don't understand much
  • input_shape: (n_samples, n_feature)
  • batch_input_shape: (n_batch, n_samples, n_features) but I'm confusing because several tutorials mention that the input of LSTM is 3D of samples, timesteps, and features.

May I have your suggestions whether my understanding is correct or not.

1

1 Answers

0
votes

"Suppose we would like to use price of 5 previous days to predict the price of 3 coming days". For this problem, a non-recurrent net with five inputs and three outputs is the natural approach. But first, it would be sensible to check for any periodicity in the data, e.g. weekly or seasonal.

Recurrent neural nets, including LSTM's, are great when your input sequences are of variable length, like sentences. They have the constraint that within a batch, each sequence should be of the same length. The shape of the input is (batch_size, sequence_length, input_dimension). Outputs are available with shape (batch_size, sequence_length, output_dimension) and (batch_size, output_dimension).