What is the difference between timesteps and features in LSTM?

437 Views Asked by At

I have a dataframe representing numerical values in many time periods, and I have formatted that dataframe in the way there are represented as a concatenation of previous values. For example:

+------+------+------+
| t1   | t2   | t3   |
+------+------+------+
| 4    | 7    | 10   |
+------+------+------+
| 7    | 10   | 8    |
+------+------+------+
| 10   | 8    | 11   |
+------+------+------+
...

When I format the dataset to work with a LSTM, I reshape it to a 3 dimensional vector [samples, time steps, features].

But, which value do I have to put for time steps and features? Should features be 3 because I learn with the last 3 elements?

By the moment I have this one:

trainX = numpy.reshape(trainX, (trainX.shape[0], 1, trainX.shape[1])) 
1

There are 1 best solutions below

0
On

I try to explain on example. So assume we have some measurement with temperature and pressure and we want to predict temperature at some point of future. We have two features right(temperature & pressure). So we can use them for feeding LSTM and try to predict. Now I'm not sure how you stand with LSTM theory, but there are two variables at game, cell state C and previous output h(t-1). We concentrate to h(t-1). So you gave LSTM cell(assume now only one neuron) input(temperature and pressure). LSTM produce output and cell state and now, if you have time steps at 1, when you give LSTM new input, output will be dependent only at cell state and input. But if your timesteps is set to five. Second input will be dependent on cell state, input and previous output. Third output will be dependent on second output, cell state, current input. This sequence continues at the moment of sixth input, when you again depend on input and cell state. These h(t-1) stuff is refereed as short time memory. So if you set time steps to 1, you loose your short memory.

Edit My bad I don't look at your data at right way. You have one feature, t and three steps. But you don't frame it right way, you treat three t values as separate features and feed LSTM with them. But you can instead reshape your data to samples x 3 x 1. So you feed LSTM with t1 of first sample, next t2 of first sample but LSTM output will be affected by output from previous time step.