Lesson 4 of 12 in this unit
Send the error backward.
Trace a mistake through two weights, calculate both gradients, and then update them together.
By the end: Distinguish backpropagation from optimization and verify a simultaneous two-weight update.
Prerequisites and path options
Why learn this? Trace a wrong update to its source so you can debug learning code and distinguish calculating gradients from changing weights.
Start with something concrete.
Imagine two volume knobs in a row. The first changes a signal, and the second changes the result. To fix the final output, you need to know how sensitive it is to each knob. A computational graph records that chain of dependencies.
Try the interactive modelBackpropagation has calculated gradients of −8 and −24. Have the weights changed yet?
Change one thing. Watch what follows.
Loading this browser experiment…
Understand what changed.
A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.
The idea in everyday terms
Think of two adjustable knobs connected in a chain. The first changes an intermediate value and the second changes the final prediction. To improve the prediction, we need to know how much each knob contributes to the error. Backpropagation calculates these sensitivities by working backward through the chain.
What to watch in the experiment
First calculate and keep the forward values. Then work backward, multiplying the sensitivities along each connection. Keep both weights fixed while calculating both gradients. Only after that does the optimizer use the gradients to change the weights together.
What this does not establish
A gradient is a local sensitivity, not a new weight or a guarantee of a better final model. Updating a weight midway changes the calculation and no longer reproduces this simultaneous update.
Open the full worked examples, calculations and limitations
This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.
First, keep the forward values
We compute h = w₁x, prediction = w₂h, and L = ½(prediction − target)². The factor ½ makes the derivative simpler; it is a different scaling from the previous lesson, so compare losses within this example.
With input 2, target 10, and weights 3 and 1, hidden value h = 6, prediction = 6, and loss = 8. Keep these intermediate values: the backward pass will reuse them.
Multiply local sensitivities along each path
The derivative of loss with respect to prediction is prediction − target, here −4. Changing w₂ changes prediction by h times as much, so its gradient is −4 × 6 = −24.
For w₁, the influence passes through h and then w₂. Multiply the local sensitivities: −4 × w₂ × x = −4 × 1 × 2 = −8. This is the chain rule: changes propagate through dependent operations.
Now the optimizer can take a step
Use gradients from the same old weights for both updates. With rate 0.01, w₁ becomes 3.08 and w₂ becomes 1.24. The new prediction is 7.6384 and the loss is about 2.7886. Updating one weight before calculating the other gradient would be a different procedure.
Backpropagation reuses intermediate values rather than perturbing every parameter and rerunning the whole model. Automatic differentiation applies these rules across large graphs. Long chains can shrink or amplify gradients; initialization, residual connections, normalization, and gradient clipping can help.
A teammate updates w₂ and then uses that new w₂ to calculate the gradient for w₁. What should you change to reproduce the simultaneous update?
Take this idea with you.
The forward pass makes a prediction, the backward pass calculates gradients, and the optimizer updates parameters. Keep those responsibilities separate.
Explore related topics and the topic map
How this topic connects
Explore this topic on the interactive mapUse these connections to review a foundation or choose where to go next. You can open any topic without completing the others.
What it builds on
- Gradient descent
Gradient descent uses a slope to update a parameter; backpropagation calculates the slopes needed when several parameters contribute to the error.
- Chain rule
Follow how a change passes through several calculations. This is the rule used to combine local sensitivities into a gradient.
Trace a mistake through two weights, calculate both gradients, and then update them together.
What it enables
- What does this neuron notice?
Inspect which input patterns change a prediction so you can question what an image model has learned.
- Compress and reconstruct
Inspect what a compressed representation keeps and loses before using it for another task.
- Generate with a variational autoencoder
Understand the tradeoff between reconstructing examples and learning a space from which new examples can be sampled.
Show 12 more connections
- Repair a broken training run
Diagnose failed learning runs systematically instead of spending more compute on the same mistake.
- Learn from small batches
Compare training recipes fairly when update counts and the number of examples processed differ.
- Initialize and normalize
Diagnose unstable activations and recognize why training and evaluation modes can behave differently.
- Trace disappearing and exploding gradients
Find why deep or repeated computations stop learning or make unstable updates.
- Make numerical computation trustworthy
Avoid overflow and misleading gradient checks when mathematically equivalent formulas behave differently on a computer.
- Compare manual and automatic gradients
Check what automatic differentiation computes so you can catch broken gradient accumulation in your own code.
- Copy a demonstrated action
Understand when demonstrations can teach a policy and why unfamiliar states can still cause failures.
- Refine an idea over several passes
Recognize when repeated computation improves an answer and when it merely settles on a wrong one.
- Learn continuous dynamics
Learn what a prediction model gains from collected motion and when a simpler baseline already earns its place before adding planning cost.
- Learn something new without losing the old
Protect an existing skill while teaching a model a new one, using explicit checks for regressions.
- Choose where a connected system learns
Choose which components to retrain while protecting the other systems that depend on their outputs.
- Train and evaluate a small neural router
Compare a learned tool selector with a fixed rule before adding training and maintenance costs.