0

I've been reading for a while about training LSTM models using tf.keras, where i did use the same framework for regression problems using simple feedforward NN architectures and i highly understand how should i prepare the input data for such models, however when it comes for training LSTM, i feel so confused about the shape of the input.

There is a lot to take care about: time steps, number of samples, batch size, number of units, etc. In addition to many parameters for the LSTM keras layer that aren't clear for me yet as what is shown in the below example:

model.add(keras.layers.LSTM(units=3, batch_input_shape=(8,2,10), return_sequence=True, stateful= True))

So I have the following forex data structure where i don't know how to reshape it properly for an LSTM model.

open | close | high | low | volume | i1 | i2 | i3 | ... | i30 | nextClose

These features represents the open/close/high/low prices of a certain currency pair, in addition to the volume and 30 different indicators' values from i1 -> i30, all of these features corresponds to one minuet tick. Besides the nextClose feature represents the next minuet tick close price value that I'm trying hopefully to predict.

Q1: Could anyone please explain the general concept of how the data should be shaped for input, and what are all of these required parameters (time step, batch size...)?

Q2: Where I think a simple example could be great, How should my data structure above be reshaped to look like a valid input for LSTM?

peter bence
  • 782
  • 3
  • 14
  • 34
  • Maybe you need [Understanding Keras LSTMs](https://stackoverflow.com/questions/38714959/understanding-keras-lstms). – giser_yugang Apr 22 '19 at 13:51
  • @giser_yugang thanks for response i will check it – peter bence Apr 22 '19 at 13:58
  • @giser_yugang please check my update – peter bence Apr 23 '19 at 14:17
  • There's no big problem. The input shape of LSTM have two formats `[timesteps,batch_size, features]` or `[batch_size,timesteps, features]` in keras. You can refer https://stackoverflow.com/questions/54764500/how-to-create-end-execute-a-basic-lstm-network-in-tensorflow/54768066#54768066. – giser_yugang Apr 24 '19 at 13:35

1 Answers1

0

After a lot of search i found this excellent summary for keras LSTM in a diagram, that was so helpful. check it in the Keras_LSTM_Diagram git repository.

peter bence
  • 782
  • 3
  • 14
  • 34