Search code examples
pythonkerasrecurrent-neural-network

Does the ordering of 'rows' at the level of timesteps matter, for a RNN input in Keras?


An RNN, in keras, accepts an input with the following shape

array([[['Xa0', 'Ya0'],
    ['Xa1', 'Ya1'],
    ['Xa2', 'Ya2']],

   [['Xb0', 'Yb0'],
    ['Xb1', 'Yb1'],
    ['Xb2', 'Yb2']],

   [['Xc0', 'Yc0'],
    ['Xc1', 'Yc1'],
    ['Xc2', 'Yc2']]], dtype='<U3')

The numbers are associated with the time steps (3 in our case), and X,Y are features. We have 3 batches (a,b,c).

Which order should I use:

  1. 0 -> 2 from past to present?
  2. 0 -> 2 from present to past?

and why?


Solution

  • What do you want to infer from the data?

    Do you want to classify it? Get a "true/false" result? Make a regression?

    Any order is ok. Use the one that gives your network the best result. There is even the possibility of using Bidirectional layers, that will read the data both from past to present and from present to past.

    Do you want to predict next steps?

    Use the order that leads to the steps you want to predict.