# Is the number of cells in a keras LSTM or RNN layer equal to the number of time steps?

Say I have the following code to create a LSTM layer:

lstm_model = Sequential()


Lets say, I plan to train a model where there are n tanks. for each tank the pressure and temperature are recorded at an interval of 1 hour, a total of 5 times everyday. The data is recorded for a year. Thus I will have batch_size = 365, time steps equal to 5 and number of features = 2. So my input shape will be (365,5,2).

So will the code mentioned earlier create an entire LSTM layer with total number of cells just equal to 5?

• Time steps is the one that determines the size, because it's the number of times that you unroll your LSTM cell. So, that is right, total number of unrolled cells is equal to $$5$$.
• The features is related to the series you want to input/predict. If it is $$1$$, the series is univariate, otherwise it is multi-variate and doesn't have anything to do with the number of cells unrolled.
• You have one cell, but it is unrolled $5$ times, so it appears as if you have $5$ due to the recursive nature.The term isn't consistent across libraries and literature by the way. – gunes Feb 4 '20 at 13:19
• The neuron concept doesn't apply well to RNNs because in feedforward nets neurons have scalar outputs. However, LSTM cell outpus the hidden state, $h_t$, which is 128 in your case. So, it's as if there are 128 neurons in the cell producing outputs. In general, the final estimation is done via a subsequent fully connected layer. I suggest you keep the two concepts separate. – gunes Feb 4 '20 at 16:07