Inside a neural network / 4 of 7

Backpropagation and the chain rule

8 minOpening your notebook…

What you’ll learn

  • Explain the main idea of “Backpropagation and the chain rule” in your own words.
  • Trace a concrete example and identify the assumptions behind it.
  • Apply the principle in a practice problem and recognize a common failure.

The idea, intuitively

Backpropagation efficiently computes how each parameter contributes to loss. It moves backward through the computation graph using the chain rule. It calculates gradients; the optimizer decides how to use them.

Treat a neural network as a computation graph, not a mysterious black box. Follow a tiny input through each operation and keep track of tensor shapes. Distinguish the forward pass, gradient computation, and optimizer update. These three stages are connected but solve different parts of the learning problem.

Under the hood

If y=f(g(x)), the derivative multiplies the outer derivative by the inner derivative. Reverse-mode automatic differentiation reuses intermediate values rather than independently perturbing every parameter.

∂L∂w=∂L∂z∂z∂w\frac{\partial L}{\partial w}=\frac{\partial L}{\partial z}\frac{\partial z}{\partial w}
The chain rule links the effect of w on the intermediate value z to the effect of z on the final loss L.
A useful caution

A gradient is a sensitivity signal, not an explanation of causality in the real world.

A worked example

For prediction wx and loss (wx−y)², the derivative with respect to w is 2(wx−y)x.

How to use this way of thinking

Build intuition with a small calculation before scaling dimensions. Check whether the architecture can represent the desired relationship, then whether optimization can learn it, then whether the learned solution generalizes. A failure in any one of these stages needs a different response.

Try it yourself

For w=2, x=3, y=4, calculate dL/dw.

Key takeaways

  • The chain rule
  • A gradient is a sensitivity signal, not an explanation of causality in the real world.
  • Check the assumptions with a small example before applying this idea to a larger system.

Check your understanding

0/2 checked

Use feedback to learn. Quiz scores and lesson completion are tracked separately.

1Which mathematical rule makes backpropagation possible?
2True or false: Backpropagation computes gradients; an optimizer uses them to update parameters.
Go to lesson completion

Further reading

Original papers and reference material for this school. External resources may be in English and require internet access.

Dive into Deep Learning (opens a new tab)PyTorch: automatic differentiation (opens a new tab)

Finish this lesson

Mark this lesson complete when you’re ready to continue.

Start with a question

Introduction to AIAI FoundationsA brief history of AIAI FoundationsTypes of AIAI FoundationsAI, ML, and deep learningAI FoundationsUnderstanding generative AIAI FoundationsEthics, limitations, and responsibilityAI FoundationsLinear algebra for learning systemsMathematics for AIVectors, matrices, and similarityMathematics for AICalculus: measuring changeMathematics for AIDerivatives and gradientsMathematics for AIProbability and statisticsMathematics for AIOptimization and objectivesMathematics for AI
K to open · Escape to close