Answers.Body: <p>LSTM can be tricky, I'll give my $0.02.</p>
  <p>LSTM input layer defines the shape so it would be something like this.</p>
  <p>If I am understanding your question correctly, your data can be framed as 184 samples with 2 time steps and 70 features?</p>
  <p>So the start of the code might look like this.</p>
  <pre><code>model = Sequential()
  model.add(LSTM(184, input_shape=(50, 2)))
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-29T14:00:54.067Z
Answers.LastActivityDate: 2023-01-20T16:13:17.440Z
Answers.LastEditDate: 2023-01-20T16:13:17.440Z
Answers.UserDisplayName: CoffeeBaconAddict
Body: <p>I am trying to train my model using LTSM layer in Keras (python). I have some problems regarding the data representation and feeding it into the model.</p>
  
  <p>My data is 184 XY coodinates encoded as a numpy array with two dimensions: one corresponding to the X or Y and second is every single point of X or Y. Shape of a single spectrum is (2, 70). Altogether, my data has a dimension of (184, 2, 70).</p>
  
  <p>The label set is an array of 8 elements which describes the percentage distribution of some 8 features which are describing XY. The shape of an output is (184, 8).</p>
  
  <p>My question is how can I train using the time series for each XY pair and compare it to the corresponding label set? Different XY data show similar features to each other that is why it is important to use all 184 sample for the training. What would be the best approach to handle this problem? Below I show the schematics of my data and model:</p>
  
  <p>Input: (184, 2, 70) (number of XY, X / Y, points)</p>
  
  <p>Output: (184, 8) (number of XY, predictions)</p>
  
  <p>I look forward for some ideas!</p>
  
  <p><a href="https://i.sstatic.net/ZkR9b.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZkR9b.jpg" alt="Data representation"></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-03T02:43:48.020Z
Comments.Text: I didn't understand your question, 184 is the length of the sequence or the size of the data set? if 184 is the data set size, then I think 70 is the sequence length, then you can use LSTM. But LSTM will out put 70 hidden states, and use the last hidden state as the output.
Comments.UserDisplayName: Louis Lv
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-05T08:17:13.097Z
Comments.Text: Thanks for the comment! Sorry for the poor explanation. I have 184 different spectra with XY coordinates (updated post with image). Each X and Y has 70 points. The data is described as the label with 8 numbers. 184 separate files is not many for training I believe so I was thinking about splitting each XY data to time series with size of 5 and using LTSM for training.
Comments.UserDisplayName: Dawid
Tags: <python><keras><time-series><long-short-term-memory>
Title: How to train a LSTM model with multi dimensional data
UserDisplayName: Dawid
ThreadText: # How to train a LSTM model with multi dimensional data
  
  (Asked by: username_0 on 2019-08-02)
  
  I am trying to train my model using LTSM layer in Keras (python). I have some problems regarding the data representation and feeding it into the model.
  
  My data is 184 XY coodinates encoded as a numpy array with two dimensions: one corresponding to the X or Y and second is every single point of X or Y. Shape of a single spectrum is (2, 70). Altogether, my data has a dimension of (184, 2, 70).
  
  The label set is an array of 8 elements which describes the percentage distribution of some 8 features which are describing XY. The shape of an output is (184, 8).
  
  My question is how can I train using the time series for each XY pair and compare it to the corresponding label set? Different XY data show similar features to each other that is why it is important to use all 184 sample for the training. What would be the best approach to handle this problem? Below I show the schematics of my data and model:
  
  Input: (184, 2, 70) (number of XY, X / Y, points)
  
  Output: (184, 8) (number of XY, predictions)
  
  I look forward for some ideas!
  
  [![Data representation](https://i.sstatic.net/ZkR9b.jpg)](https://i.sstatic.net/ZkR9b.jpg)
  
  **Tags:** python, keras, time-series, long-short-term-memory
  > **Comments:**
  > **username_1**: I didn't understand your question, 184 is the length of the sequence or the size of the data set? if 184 is the data set size, then I think 70 is the sequence length, then you can use LSTM. But LSTM will out put 70 hidden states, and use the last hidden state as the output.  
  > **username_0**: Thanks for the comment! Sorry for the poor explanation. I have 184 different spectra with XY coordinates (updated post with image). Each X and Y has 70 points. The data is described as the label with 8 numbers. 184 separate files is not many for training I believe so I was thinking about splitting each XY data to time series with size of 5 and using LTSM for training.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-08-29. Score: 0
  
  LSTM can be tricky, I'll give my $0.02.
  LSTM input layer defines the shape so it would be something like this.
  If I am understanding your question correctly, your data can be framed as 184 samples with 2 time steps and 70 features?
  So the start of the code might look like this.
  model = Sequential()
  model.add(LSTM(184, input_shape=(50, 2)))
  
  
  ---
  
  