page_title: Backpropagation through time
section_title: Algorithm
hierarchical_section_title: Backpropagation through time / Algorithm
caption_attribution_description: English: Backpropagation through time
context_page_description: Backpropagation through time is a gradient-based technique for training certain types of recurrent neural networks. It can be used to train Elman networks. The algorithm was independently derived by numerous researchers.
context_section_description: The training data for a recurrent neural network is an ordered sequence of  input-output pairs, . An initial value must be specified for the hidden state . Typically, a vector of all zeros is used for this purpose.
  BPTT begins by unfolding a recurrent neural network in time. The unfolded network contains  inputs and outputs, but every copy of the network shares the same parameters. Then the backpropagation algorithm is used to find the gradient of the cost with respect to all the network parameters.
  Consider an example of a neural network that contains a recurrent layer  and a feedforward layer . There are different ways to define the training cost, but the total cost is always the average of the costs of each of the time steps. The cost of each time step can be computed separately. The figure above shows how the cost at time  can be computed, by unfolding the recurrent layer  for three time steps and adding the feedforward layer . Each instance of  in the unfolded network shares the same parameters. Thus the weight updates in each instance () are summed together.
caption: BPTT unfolds a recurrent neural network through time.
exif: {}