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

  • 1
    $\begingroup$ 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. $\endgroup$
    – Louis Lv
    Aug 3, 2019 at 2:43
  • 1
    $\begingroup$ 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. $\endgroup$
    – Dawid
    Aug 5, 2019 at 8:17

1 Answer 1


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)))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .