Backpropagation through time
What Is Backpropagation Through Time?
Backpropagation through time, usually abbreviated BPTT, is the algorithm used to compute the gradient of a loss function with respect to the weights of a recurrent neural network. It works by unfolding the recurrence over a finite number of time steps into an equivalent feedforward computation graph in which the same weight matrices appear at every step, then applying ordinary backpropagation to that graph. Because the weights are shared across steps, the gradient with respect to any weight is the sum of the contributions accumulated at every time step in which that weight was used. Paul Werbos set out the method and its practical variants in the 1990 Proceedings of the IEEE paper Backpropagation through time: what it does and how to do it, which remains the standard reference for the formulation.
BPTT is not a separate learning rule so much as an application of reverse-mode automatic differentiation to a graph with cycles removed by unrolling. That framing explains both its efficiency, since one backward pass costs about the same as one forward pass, and its principal limitation, since the entire sequence of intermediate activations must be retained until the backward pass consumes them.
Unfolding the Recurrence
An unfolded network of length T is a feedforward network with T copies of the recurrent layer, each copy receiving the input at its time step and the hidden state produced by the previous copy. The forward pass proceeds left to right and stores every hidden state. The backward pass proceeds right to left, propagating the derivative of the loss with respect to each hidden state backward through the recurrent Jacobian and accumulating weight gradients along the way. Both time and memory scale linearly with sequence length. Gradient checkpointing trades some of that memory for recomputation by storing hidden states only at intervals and regenerating the rest during the backward pass. An alternative family of algorithms, notably real-time recurrent learning, computes the same gradient in the forward direction without storing history, but its cost per step grows much faster with network size, which is why BPTT dominates in practice. Chapter 10 of the Deep Learning textbook by Goodfellow, Bengio, and Courville develops the unfolding argument and the resulting update equations.
Truncated Backpropagation Through Time
Long or unbounded sequences make full unrolling impractical, so implementations use truncated BPTT. The sequence is processed in consecutive segments: the forward pass carries the hidden state across segment boundaries, but the backward pass is cut off after a fixed number of steps, so gradients never flow further back than the truncation window. The scheme is often described by two parameters, the number of steps between successive updates and the number of steps the gradient is propagated backward. Truncation makes cost per update constant and allows online learning on streaming data, at the price of a biased gradient estimate that cannot capture dependencies longer than the window.
Gradient Stability
Propagating a derivative backward across many steps multiplies a long chain of Jacobians, and the norm of that product tends to shrink or grow geometrically. The result is the vanishing and exploding gradient problem: distant time steps contribute almost nothing to the update, or contribute so much that the update is destructive. The analysis in On the difficulty of training recurrent neural networks relates the two behaviors to the spectral radius of the recurrent weight matrix and proposes gradient norm clipping for the exploding case together with a regularizer for the vanishing case. Gated architectures, principally long short-term memory and the gated recurrent unit, address the vanishing case structurally by providing an additive path along which the gradient can travel across many steps without repeated multiplication.
Applications
Backpropagation through time is used to train models in areas including:
- Speech recognition and speaker modeling
- Language modeling, translation, and sequence labeling
- Time series forecasting in finance, energy, and hydrology
- System identification and model-based control of dynamic plants
- Handwriting and gesture recognition
- Biosignal analysis, including electrocardiogram and electroencephalogram classification