What is backpropagation inside a neural network

What is backpropagation inside a neural network

If you ask what is backpropagation, the short answer is that it is the method neural networks use to work out how each weight should change during training. It takes the error at the output, pushes that information backwards through the network, and turns it into many small gradients that tell us which weights should rise, which should fall, and by how much.

This matters because a neural network does not learn by guessing whole solutions. It learns by making a prediction, measuring how wrong that prediction is, and then changing millions or billions of parameters a little at a time. Backpropagation is the efficient way to compute those changes.

What is backpropagation in one sentence

Backpropagation is an efficient way to compute the gradient of the loss with respect to every weight in a neural network by using the chain rule from calculus.

The idea is easiest to see as a pipeline. A network first computes an output in the forward pass. Then a loss function compares that output with the target. Backpropagation starts from that loss and moves backwards, layer by layer, to find how much each earlier value contributed to the final error.

If you have already read what a gradient is and why every AI model follows one, this will feel familiar. The gradient says how the loss changes if we nudge a parameter. Backpropagation is the machinery that computes those gradients for every parameter in a network.

The chain rule idea behind the backward pass

Neural networks are built from simple functions stacked together. If one layer feeds into another, then the final loss depends on an early weight through several intermediate steps. The chain rule tells us how to differentiate such a composition.

Suppose a tiny network does this:

\[ z = wx, \quad a = \, z, \quad L = \frac{1}{2}(a - y)^2 \]

Here \(x\) is the input, \(w\) is the weight, \(a\) is the prediction, \(y\) is the target, and \(L\) is the loss. To see how the loss changes when \(w\) changes, we multiply three derivatives:

\[ \frac{\partial L}{\partial w} = \frac{\partial L}{\partial a} \cdot \frac{\partial a}{\partial z} \cdot \frac{\partial z}{\partial w} \]

That product is the chain rule in action. Each factor is local. One depends on the loss and output, one on the activation function, and one on the linear part of the layer. Backpropagation reuses these local pieces instead of redoing the whole calculation for every weight.

For a deeper look at the role of derivatives in training, see the article what a gradient is and why every AI model follows one. For a broader map of the ideas around this topic, the best match in the masterclass is Neural Networks and Backpropagation.

A small numeric example with one weight update

Let us use real numbers. Take one input \(x = 2\), one weight \(w = 0.5\), and one target \(y = 1\). The prediction is

\[ a = wx = 0.5 \times 2 = 1 \]

The loss is

\[ L = \frac{1}{2}(a - y)^2 = \frac{1}{2}(1 - 1)^2 = 0 \]

In this exact case the model is already correct, so the gradient is zero and the weight does not change. To show an update, keep the same input and weight but change the target to \(y = 2\).

Now the prediction is still \(a = 1\), and the loss becomes

\[ L = \frac{1}{2}(1 - 2)^2 = \frac{1}{2} \]

Compute the gradient:

\[ \frac{\partial L}{\partial a} = a - y = 1 - 2 = -1 \]

\[ \frac{\partial a}{\partial w} = x = 2 \]

So

\[ \frac{\partial L}{\partial w} = -1 \times 2 = -2 \]

If we use a learning rate of \(0.1\), gradient descent updates the weight by

\[ w_{\text{new}} = w - 0.1 \cdot (-2) = 0.5 + 0.2 = 0.7 \]

The weight moved up because the gradient was negative. That makes sense: increasing \(w\) makes the output larger, which moves the prediction towards the target \(2\).

This tiny example has only one weight, but the same logic scales to a large network with many layers. Backpropagation gives every weight its own gradient, even when the final loss depends on that weight through a long chain of calculations.

Why backpropagation is the core of training neural networks

Training means improving the network by lowering the loss. Backpropagation is the standard way to find the direction in parameter space that lowers that loss fastest, at least locally. Without it, a modern neural network would be very hard to train, because manual tuning of millions of weights is impossible in practice.

There is also a computational reason. A network can contain many layers, and each layer can have many parameters. Backpropagation stores intermediate values from the forward pass, then reuses them during the backward pass. This makes gradient computation practical on GPUs and other accelerators.

That is why classic papers on neural networks treat backpropagation as the key training algorithm, including the early work on multilayer perceptrons by David Rumelhart, Geoffrey Hinton, and Ronald Williams in 1986, and later large-scale training work such as LeCun, Bottou, Orr, and Müller in 2012 on efficient gradient-based learning. For a clear modern overview of optimisation and backpropagation, see Goodfellow, Bengio, and Courville's Deep Learning and the discussion in Bergstra and Bengio 2012 on practical optimisation choices.

What changes during a backward pass

During backpropagation, each layer receives an error signal from the layer after it. It combines that signal with the derivative of its own operation. A linear layer uses the input values, an activation function uses its slope at the current point, and the result becomes the error signal for the previous layer.

  • The forward pass computes predictions.
  • The loss function measures the mismatch with the target.
  • The backward pass applies the chain rule to every layer.
  • The optimiser uses those gradients to update the weights.

That cycle repeats over and over on training data. Each pass may make only a small change, but many small changes can reshape the whole model. If you want the surrounding context, why a learning rate that is too large ruins everything shows what can happen when those updates are too aggressive, and how to read an AI paper as a beginner helps when you start seeing terms such as loss, gradient, and optimiser in research papers.

Backpropagation is the main subject in Unit 6 of the masterclass, and the next stage is Training Deep Networks, where the same ideas are used in larger models with more layers and more careful optimisation.

Frequently asked questions

Does backpropagation change the weights directly

No. Backpropagation computes the gradients, and the optimiser, such as gradient descent, uses those gradients to update the weights.

Why do we need the chain rule

Because the loss depends on early weights through many intermediate operations. The chain rule lets us split that long dependency into small derivative steps.

Can a neural network train without backpropagation

Some systems use other methods, but backpropagation is the standard approach for training most modern neural networks because it is efficient and works well at scale.

Learn how machines learn, properly

The AI Masterclass: weekly units, quizzes, a final exam, and a certificate.
About the program