Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Sequence length in LSTM?

The dimensions for the input data for LSTM are [Batch Size, Sequence Length, Input Dimension] in tensorflow.

  1. What is the meaning of Sequence Length & Input Dimension ?
  2. How do we assign the values to them if my input data is of the form : [[[1.23] [2.24] [5.68] [9.54] [6.90] [7.74] [3.26]]] ?
like image 581
Stuti Kalra Avatar asked Mar 30 '18 11:03

Stuti Kalra


1 Answers

LSTMs are a subclass of recurrent neural networks. Recurrent neural nets are by definition applied on sequential data, which without loss of generality means data samples that change over a time axis. A full history of a data sample is then described by the sample values over a finite time window, i.e. if your data live in an N-dimensional space and evolve over t-time steps, your input representation must be of shape (num_samples, t, N).

Your data does not fit the above description. I assume, however, that this representation means you have a scalar value x which evolves over 7 time instances, such that x[0] = 1.23, x[1] = 2.24, etc.

If that is the case, you need to reshape your input such that instead of a list of 7 elements, you have an array of shape (7,1). Then, your full data can be described by a 3rd order tensor of shape (num_samples, 7, 1) which can be accepted by a LSTM.

like image 178
KonstantinosKokos Avatar answered Sep 21 '22 15:09

KonstantinosKokos