Skip to content
atlas

Backpropagation

Also known as: backprop, backward pass

The bookkeeping method that works out, layer by layer from the output back, how much each weight in a network added to its mistake.

Draft - this entry has not been reviewed yet.

Formal

A method for computing, in one backward sweep through a neural network, how the loss would change if each weight changed; gradient descent then uses those numbers to update the model weights.

In plain English

Like a kitchen following a burnt dish back through every cook who touched it, deciding how much blame each one carries, so each knows how much to change next time.

In practice

A developer at a Danish logistics firm trains a network to read handwritten house numbers on parcels; when it reads a 7 as a 1, backpropagation passes that error back through every layer and gives each weight its share of the blame.

Why it matters

Without a cheap way to share out blame, networks with many layers would take far too long to train; this method, together with fast hardware, is what made deep learning practical.

Technical deep dive

Backpropagation is reverse-mode automatic differentiation applied to a network's computational graph. The forward pass computes and stores each layer's pre-activations z and activations a; the backward pass then applies the chain rule from the scalar loss towards the input. For a fully connected layer l the error signal is δˡ = (Wˡ⁺¹)ᵀ δˡ⁺¹ ⊙ σ′(zˡ), and the weight gradient is ∂L/∂Wˡ = δˡ (aˡ⁻¹)ᵀ. Because the loss is a single scalar, one backward sweep yields the partial derivative for every parameter at a cost of only a small constant multiple of the forward pass, whereas finite differences would need one extra forward pass per parameter, which means billions of passes for a modern model. A widely used rule of thumb puts training compute at about 6N FLOPs per token for a model with N parameters: roughly 2N forward and 4N backward.

The idea predates its fame. Seppo Linnainmaa described reverse-mode differentiation in 1970, Paul Werbos proposed applying it to neural networks in his 1974 thesis, and Rumelhart, Hinton and Williams popularised it in Nature in 1986 by showing that it learns useful internal representations in hidden layers. A frequent misconception is that backpropagation is the learning algorithm; it only computes gradients, and an optimiser such as SGD or Adam decides how to change the weights with them.

The main engineering cost is memory. Every intermediate activation needed for the backward pass must be kept until it is used, so memory grows with depth, batch size and sequence length. Activation (gradient) checkpointing stores only some activations and recomputes the rest during the backward pass, cutting memory to roughly the square root of the number of layers at the price of an extra partial forward pass (Chen et al., 2016). Mixed-precision training uses loss scaling so that small FP16 gradients do not underflow to zero. In PyTorch, loss.backward() walks a dynamically recorded graph and accumulates into each parameter's .grad, which is why gradients must be zeroed between steps unless accumulation is intended.

Gradients multiplied through many layers can shrink or grow exponentially. Vanishing gradients, analysed by Hochreiter (1991) and Bengio et al. (1994), made deep sigmoid networks and recurrent networks trained by backpropagation through time hard to train; exploding gradients cause divergence. The standard remedies (ReLU-family activations, variance-preserving initialisation (Glorot, He), residual connections, normalisation layers, LSTM gating and gradient-norm clipping) are all ways of keeping the backward signal well conditioned. Operations with no useful derivative, such as sampling or rounding, need surrogates like the straight-through estimator or score-function (REINFORCE) gradients.

What to learn first

Everything this builds on, foundations first.

  1. Neural network
  2. →Training data
  3. →Machine learning
  4. →Loss function
  5. →Model parameter
  6. →Gradient descent
  7. →Backpropagation

Relationships

Sources & further reading

Where this data comes from

This entry was drafted by an AI from the sources above and has not yet been checked by a person. Treat it as a starting point, and check anything important against the sources.

See the review queueSuggest a correction on GitHubThis term as JSON

Check yourself

Loading…

Atlas is in beta.