Dictionary of Applied Machine Learning: 151 machine-learning terms, each with a definition, a figure, citations and a Python demo · All terms · Demos · Start here

backpropagation

Updated on 2026-11-10

Readiness 100/100

▶ Run the Python demo Open in Colab Typeset PDF LaTeX source Markdown Cite this entry

See also artificial neural network deep net gradient gradient descent edge weight

Backpropagation is an algorithm that computes the gradient of the loss with respect to the model parameters of an artificial neural network (ANN). The algorithm consists of two consecutive phases, referred to as forward and backward pass. The forward pass evaluates, for the current model parameters, the activations and the resulting prediction errors on a given dataset. The backward pass then applies the chain rule to compute the partial derivatives of the average loss with respect to the model parameters. These partial derivatives constitute a gradient, which can be used in a gradient step to update the model parameters.

Figure produced by the Python demo of the entry backpropagation
Figure written by the entry's Python demo backpropagation.py, which recomputes what the entry states: the script block by block · open in Colab

Definition

Consider an artificial neural network (ANN) with a billion model parameters and its prediction for a new data point. If this prediction is wrong, the model parameters can be updated by a gradient step. That update requires the partial derivatives of the loss on the new data point with respect to all model parameters.

Backpropagation is an algorithm for computing these partial derivatives with as little duplicated computation as possible (Goodfellow et al., 2016, Sect. 6.5.3; Rumelhart et al., 1986). More generally, it computes the gradient $\nabla f({\mathbf w})$ of an objective function $f({\mathbf w})$ with respect to the model parameters ${\mathbf w}$ of the ANN. The model parameters consist of the edge weights and the offset terms at the nodes of the ANN. The objective function is typically the average loss \[ f({\mathbf w}) = \frac{1}{m} \sum_{r=1}^{m} L\left(\left( {\mathbf x}^{(r)},y^{(r)} \right),h^{({\mathbf w})} \right) \text{,} \] incurred on a dataset of $m$ data points $\left( {\mathbf x}^{(1)},y^{(1)} \right), \ldots, \left( {\mathbf x}^{(m)},y^{(m)} \right)$. Backpropagation computes the partial derivatives of $f({\mathbf w})$ one layer at a time (Fig. 1). Its execution consists of two consecutive phases, the forward pass and the backward pass.

B-backwardIn the forward pass, the ANN is applied to each data point of the dataset: the neurons of each layer evaluate their activations from the activations of the previous layer. The final layer then produces the output, which is the prediction for the label of a data point with features ${\mathbf x}$. The quality of this prediction is measured by a loss function $L\left(\left( {\mathbf x},y \right),h^{({\mathbf w})} \right)$, where $h^{({\mathbf w})}$ is the hypothesis map represented by the ANN with model parameters ${\mathbf w}$. In the backward pass, the partial derivatives of $f({\mathbf w})$ with respect to the edge weights of each layer are computed recursively, from the output back to the input. These partial derivatives form the whole gradient $\nabla f({\mathbf w})$. The backward pass requires about as much computation as the forward pass: its cost grows in proportion to the number of edges of the ANN, one partial derivative, one multiplication, and one addition per edge (Goodfellow et al., 2016, Sect. 6.5.3).

Figure 1 of the entry backpropagation
Figure 1: Backpropagation through an ANN with one hidden layer. The solid arrows indicate the forward pass: the features $\feature_{1},\feature_{2},\feature_{3}$ reach the neurons $a_{1},a_{2},a_{3}$ through the edge weights $\mW^{(1)}$, then the output $\predictedlabel = \hypothesis^{(\weights)}(\featurevec)$ through $\mW^{(2)}$. The output is a prediction for the label of a data point and incurs the loss $f(\weights)$. The dashed arrow indicates the backward pass, which runs the other way and yields the partial derivatives of $f(\weights)$ with respect to the edge weights of both layers. The model parameters $\weights$ collect the edge weights of both layers; the offset terms of the neurons are omitted here
To illustrate the details of backpropagation, consider a simple ANN: it consists of three layers with one neuron each. Its model parameters are the three edge weights $w^{(1)}, w^{(2)}, w^{(3)}$. The gradient of an average is the average of the gradients of its summands, so a dataset with a single data point already shows the recursion. The objective function $f({\mathbf w})$ is then the loss of that data point. Write $a^{(0)} = x$ for its feature. Layer $\ell = 1, 2, 3$ computes \[ z^{(\ell)} = w^{(\ell)} a^{(\ell-1)} \text{,} \qquad a^{(\ell)} = \sigma\big(z^{(\ell)}\big) \text{,} \] with the activation function $\sigma$ and no offset terms. The output is $h^{({\mathbf w})}(x) = a^{(3)}$. The edge weight $w^{(3)}$ enters $f({\mathbf w})$ only through $z^{(3)}$, $w^{(2)}$ through $z^{(2)}$ and then $z^{(3)}$, and $w^{(1)}$ through all three.

The chain rule therefore gives \[ \begin{aligned} \frac{\partial f}{\partial w^{(3)}} &= \frac{\partial f}{\partial a^{(3)}}\, \sigma'\big(z^{(3)}\big)\, a^{(2)} \text{,} \\ \frac{\partial f}{\partial w^{(2)}} &= \frac{\partial f}{\partial a^{(3)}}\, \sigma'\big(z^{(3)}\big)\, w^{(3)}\, \sigma'\big(z^{(2)}\big)\, a^{(1)} \text{,} \\ \frac{\partial f}{\partial w^{(1)}} &= \frac{\partial f}{\partial a^{(3)}}\, \sigma'\big(z^{(3)}\big)\, w^{(3)}\, \sigma'\big(z^{(2)}\big)\, w^{(2)}\, \sigma'\big(z^{(1)}\big)\, x \text{.} \end{aligned} \] Each line repeats the one above it and appends two factors. Evaluating the three lines separately would recompute the repeated factors twice over. Backpropagation computes them once, from the output backwards. The repeated factors form the partial derivative of $f({\mathbf w})$ with respect to $z^{(\ell)}$. This partial derivative obeys its own recursion, \[ \frac{\partial f}{\partial z^{(3)}} = \frac{\partial f}{\partial a^{(3)}} \sigma'\big(z^{(3)}\big) \text{,} \qquad \frac{\partial f}{\partial z^{(\ell)}} = \frac{\partial f}{\partial z^{(\ell+1)}} w^{(\ell+1)} \sigma'\big(z^{(\ell)}\big) \quad \text{for } \ell = 2, 1 \text{.} \] Each edge weight then costs one multiplication, \[ \frac{\partial f}{\partial w^{(\ell)}} = \frac{\partial f}{\partial z^{(\ell)}} a^{(\ell-1)} \text{.} \] The backward pass is this recursion, and the activations $a^{(\ell)}$ it needs are the ones the forward pass already computed.

B-gdThe partial derivatives delivered by backpropagation constitute the gradient used in a gradient step: \[ {\mathbf w}^{(t+1)} = {\mathbf w}^{(t)} - \eta \nabla f({\mathbf w}^{(t)}) \text{, for } t = 0,1,\ldots \text{,} \] with step size $\eta$. Each gradient step requires a new run of backpropagation, since the model parameters change after each step. These partial derivatives are not only used for a gradient step. A class activation map (CAM) explains a prediction of a convolutional neural network (CNN) by weighting its feature maps with partial derivatives of the output (Selvaraju et al., 2017).

See also: artificial neural network, deep net, gradient, gradient descent, gradient step, layer, edge weight, model parameter, activation function, loss function, neuron.

References

  1. Goodfellow et al. (2016). Deep Learning. MIT Press.
  2. Rumelhart et al. (1986). Learning Representations by Back-Propagating Errors. Nature. doi.org/10.1038/323533a0
  3. Selvaraju et al. (2017). Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization. 2017 IEEE Int. Conf. Comput. Vis.. doi.org/10.1109/ICCV.2017.74

Cite this entry

@misc{dictml_backpropagation,
  author = {Jung, Alexander},
  editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
  title = {backpropagation},
  howpublished = {Dictionary of Applied Machine Learning (course edition)},
  year = {2026},
  doi = {10.5281/zenodo.21569296},
  note = {ISBN 978-952-64-3013-3, CC BY 4.0, retrieved 2026-11-26},
  url = {https://dictionaryofml.org/terms/backpropagation.html}
}