Search code examples
neural-networkkerasbackpropagationrecurrent-neural-network

Backpropagation through time in stateful RNNs


If I use a stateful RNN in Keras for processing a sequence of length N divided into N parts (each time step is processed individually),

  1. how is backpropagation handled? Does it only affect the last time step, or does it backpropagate through the entire sequence?
  2. If it does not propagate through the entire sequence, is there a way to do this?

Solution

  • The back propagation horizon is limited to the second dimension of the input sequence. i.e. if your data is of type (num_sequences, num_time_steps_per_seq, data_dim) then back prop is done over a time horizon of value num_time_steps_per_seq Take a look at

    https://github.com/fchollet/keras/issues/3669