<p>I am a beginner and I have a hard time understanding inputs and outputs of LSTM.</p>
<p>So from the begining, I am trying to create multivariate input&amp;output LSTM for time series forecasting.
Thankfully I've managed to operate on multivariate inputs&amp;outputs, but, what I don't understand are the indices and what is stored in them.</p>
<p>For example, I have an intial input 2d numpy array of 4 variables:</p>
<pre><code>a  b  c  d
1  2  3  4
5  6  7  8
9 10 11 12
</code></pre>
<p>Lets say that the shape of this array is 5000x4 - thus 4 features and 5000 rows,
So for the LSTM input I'd need an array of <code>x_train = (samples, timesteps, 4 features)</code>,
And the code for input is as following:</p>
<pre><code>   model = keras.models.Sequential([
    keras.layers.LSTM(128, return_sequences=True, input_shape=[None, 4]),
    ...
    keras.layers.Dense(4)
])
</code></pre>
<p>Also since I want 4 features as output I need 4 output neurons.</p>
<p>Now for example my <code>y_train</code> values are in the following array:</p>
<pre><code>y_train = (samples, timesteps, 4 features)
</code></pre>
<p>Now I'd like to understand in what dimension (samples, timesteps or 4 features) in x_train should be values from inital array?
To what values timesteps dimension points, same question about samples and features.</p>
<p>Now let's say I've trained my model, from the output and I get predictions array of the same dimensions as <code>x_train</code> and <code>y_train</code>, in what dimension are the exact predictions?
Since I'd like to plot them or something with them?</p>
<p>EDIT: Additional question
What type of data should be stored in samples, timesteps, features.
Can you give me a simple example?</p>

CC BY-SA 4.0
2022-01-17T09:55:58.790Z
Rather than writing "Need help understanding X and doing Y", can you please just put your **specific** question in the title?
nbro
CC BY-SA 4.0
2022-01-17T10:05:16.280Z
@nbro done, hope it's ok
Puchatek Kubuś
<long-short-term-memory>
LSTM - What kind of data should contain every dimension of input LSTM matrix, where does specific dimension points to?
Puchatek Kubuś
# LSTM - What kind of data should contain every dimension of input LSTM matrix, where does specific dimension points to?

(Asked by: username_0 on 2022-01-17)

I am a beginner and I have a hard time understanding inputs and outputs of LSTM.
So from the begining, I am trying to create multivariate input&output LSTM for time series forecasting.
Thankfully I've managed to operate on multivariate inputs&outputs, but, what I don't understand are the indices and what is stored in them.
For example, I have an intial input 2d numpy array of 4 variables:
a  b  c  d
1  2  3  4
5  6  7  8
9 10 11 12

Lets say that the shape of this array is 5000x4 - thus 4 features and 5000 rows,
So for the LSTM input I'd need an array of x_train = (samples, timesteps, 4 features),
And the code for input is as following:
   model = keras.models.Sequential([
    keras.layers.LSTM(128, return_sequences=True, input_shape=[None, 4]),
    ...
    keras.layers.Dense(4)
])

Also since I want 4 features as output I need 4 output neurons.
Now for example my y_train values are in the following array:
y_train = (samples, timesteps, 4 features)

Now I'd like to understand in what dimension (samples, timesteps or 4 features) in x_train should be values from inital array?
To what values timesteps dimension points, same question about samples and features.
Now let's say I've trained my model, from the output and I get predictions array of the same dimensions as x_train and y_train, in what dimension are the exact predictions?
Since I'd like to plot them or something with them?
EDIT: Additional question
What type of data should be stored in samples, timesteps, features.
Can you give me a simple example?

**Tags:** long-short-term-memory

> **Comments:**
> **username_1**: Rather than writing "Need help understanding X and doing Y", can you please just put your **specific** question in the title?  
> **username_0**: @username_1 done, hope it's ok  

---

## 0 answers

