SeeingML
Neural Networks & Deep Learning Guide 3 of 6 · tap to switch
✦ Interactive Visual Guide 9 min · 4 hands-on labs · Beginner friendly

Backpropagation

See how neural networks pass blame backward from a wrong guess to every weight in one efficient Chain Rule sweep.

Imagine a three-station pizza kitchen (Dough -> Oven -> Delivery) trying to get a fresh pizza to a customer’s door in 20 minutes. Today it arrives 6 minutes late. How do you fix tomorrow’s timing? You walk backward from the front door: how much delay came from Delivery, how much came from the Oven, and how much started back at Dough?

Backpropagation (popularized by Rumelhart, Hinton & Williams in 1986) runs that exact backward blame-check inside a neural network!

To see every station clearly, Lab 1 shrinks a neural network down to a tiny kitchen line with five boxes from left to right:

  • Input (written x = 2.0): the order ticket entering the line (fixed data, not a knob we tune).
  • Score (written z1): station 1 multiplies the Input by its tuning knob, Layer 1 Weight (w1), and adds a steady offset called a bias (+ 0.5).
  • Active Output (written h): a one-way switch (ReLU, from the previous chapter) lets positive scores pass straight through (x1 ON) or shuts zero and negative scores down to 0.00 (x0 OFF).
  • Prediction (written ŷ): station 2 multiplies that Active Output by a second knob, Layer 2 Weight (w2), to produce the network’s final guess.
  • Error / Loss: compares the Prediction against the target (8.0) and scores how far off the guess landed.

Every training round makes two sweeps across those five stations:

  1. Forward Pass (Green arrows, left to right): Push the Input through Score, Active Output, and Prediction, then measure the Error (Loss) against target 8.0.
  2. Backward Pass (Coral arrows, right to left): Walk backward from the Error, multiplying each station’s local sensitivity (how much a tiny nudge there moves the next station) by the blame arriving from ahead. That chained multiplication is the Chain Rule, and the final blame score each weight receives is its Gradient (written in math as ∂Loss / ∂w, meaning “how fast the Error moves when this weight changes”).

Use the pass toggle below to inspect 1. Forward and 2. Backward separately or together, then drag Layer 1 Weight (w1) and Layer 2 Weight (w2). Try dragging w1 negative (below -0.2) to watch the ReLU gate flip to x0 OFF and block backward blame from reaching w1!

Interactive Lab 1: Forward Pass & Backward Blame Graph
1. Forward Pass (Left -> Right): turn Input into Score, Active Output, Prediction, and Error+ b (0.5)w1=1.0w2=1.5x1 ONBlame on w1 (∂L/∂w1)-12.75Blame on w2 (∂L/∂w2)-10.63Inputx2.00Fixed inputno knobScorez1 = w1*x + b2.50Blame (∂L/∂z1)-6.38Active Outputh = ReLU(z1)2.50Blame (∂L/∂h)-6.38Predictionŷ = w2*h3.75Error slope (∂L/∂ŷ)-4.25Error (Loss)target = 8.09.03Start blame1.002. Backward Blame (Right -> Left): multiply Error slope by each local slope
Forward Pass Arithmetic (Left -> Right)
Score = 1.0 x 2.0 + 0.5 = 2.50
Active Output = ReLU(2.50) = 2.50
Prediction = 1.5 x 2.50 = 3.75 (Target: 8.00)
Chain Rule Multiplication (Right -> Left)
Error slope = 3.75 - 8.00 = -4.25
Blame on w2 = (-4.25) x 2.50 = -10.63
Blame on w1 = (-4.25) x 1.5 x 1 x 2.0 = -12.75
Try dragging Weight 1 below -0.2 to watch ReLU slam the backward blame gate shut.
1.0
1.5
Prediction (3.75) is too low compared to Target 8.00, so Error slope is negative (-4.25) and both blame scores are negative (-12.75 and -10.63). Subtracting a negative blame nudges BOTH weights upward!

How Backpropagation Updates Neural Network Weights

Notice a classic distinction that trips up beginners: Backpropagation only measures the blame (the gradient) for each weight. By itself, it does not move a single knob! Just like a kitchen audit report tells you which station ran slow before anyone changes a recipe, Backpropagation hands every weight a blame score, and a separate update step turns the knobs afterward.

Why do we subtract that blame score when turning each knob? Think about what the sign of blame means:

  • Suppose the network’s Prediction (3.00) is way too low compared to Target 8.00. Turning a weight up lifts the Prediction closer to 8.00 and pushes the Error down, so its blame score is negative (at Step 0 below, w1 gets -15.0).

  • To nudge the weight gently instead of leaping wildly, we multiply the blame by a small fraction called the step size (also known as the learning rate, which we will explore deeply in the next chapter; here we use 0.04) and subtract it:

    new weight = old weight - step size × blame

  • Subtracting a negative number is the same as adding! On Step 1 below, w1 moves from 0.80 to 0.80 - 0.04 × (-15.0) = 0.80 + 0.60 = 1.40, lifting the Prediction sharply toward 8.00.

  • And if the Prediction ever overshoots above 8.00, blame flips positive, so subtracting a positive nudge automatically pulls the knobs gently back down.

Click Run 1 Backprop Step -> below repeatedly to watch w1, b1, and w2 apply that exact rule, watch how a tiny overshoot on Step 2 automatically corrects itself, and see Error drop smoothly toward 0.00!

Interactive Lab 2: Watch Backprop Update Weights Step by Step
Step 0/10 | Error: 12.50
Error (Loss)0.06.312.5Step 0Step 2Step 4Step 6Step 8Step 10Prediction = 3.00 (Target = 8.00)
Prediction Progress (0.00 to 10.00)Current: 3.00 | Target: 8.00
Layer 1 Weight (w1)
0.80
Blame: -15.0
Bias (b1)
0.40
Blame: -7.5
Layer 2 Weight (w2)
1.50
Blame: -10.0
Starting state (Step 0): Prediction is 3.00, far below Target 8.00 (Error = 12.50). All three blame scores are negative (-15.0, -7.5, -10.0). Using the rule new weight = old weight - step size × blame (step size = 0.04), subtracting negative blame will lift every knob upward. Click "Run 1 Backprop Step ->" to see the first move!

Why deep chains vanish or explode (and how Gradient Clipping saves you)

Because Backpropagation multiplies local slopes backward through every layer (layer 4 × layer 3 × layer 2 × layer 1), any steady drift away from 1.0× compounds exponentially across a deep stack:

  • If every layer shrinks the signal to 0.3×, after just 4 layers only 0.3 × 0.3 × 0.3 × 0.3 = 0.008× survives. Early layers hear practically nothing and freeze in place (Vanishing Gradients).
  • If every layer boosts the signal by 2.2×, after 4 layers it snowballs to 23.4×. Across 20 or 50 layers, the numbers grow past the largest value a computer can represent and turn into NaN (“Not a Number”), crashing a multi-day training run (Exploding Gradients).

Engineers keep deep blame chains healthy using three practical safeguards:

  1. Balanced starting weights (1.0× per layer): Choose initial random weights scaled carefully to each layer’s width so signals neither fade nor snowball on the first pass (known officially as He initialization for ReLU networks and Xavier initialization for smooth S-curve layers).
  2. Shortcut lanes across layers: Wire a direct bypass path that lets blame travel past a block of layers without being shrunk to zero (Skip Connections, the backbone of modern ResNets and Transformers).
  3. Capping runaway blame: Put a safe speed limit on how large a blame update can get so one wild training batch can never blow weights up into NaN overflow, while keeping the exact same downhill direction (Gradient Clipping).

Lab 3 starts in danger mode with Huge Weights (2.2×). First click Gradient Clipping: OFF to switch the safety cap ON and watch the runaway bars snap back to 5.0×, then compare Balanced Start (1.0×) and Tiny Weights (0.3×) against the 1.0× healthy baseline!

Interactive Lab 3: The Chain Rule Multiplier (Vanishing vs. Exploding Blame)
Exploding (> 5.0×, NaN risk!)
After 1 Layer
2.20×
0.01×1.0×50×
After 2 Layers
4.84×
0.01×1.0×50×
After 3 Layers
10.6×
0.01×1.0×50×
After 4 Layers
23.4×
0.01×1.0×50×
Vertical tick = 1.0× Healthy baseline (log scale)
2.2× per layer -> 23.4× after 4 layers
Exploding blame! Multiplying by 2.2× four times snowballs blame to 23.4×! In a deep network, numbers overflow past computer limits into NaN ("Not a Number") and crash training. Click "Gradient Clipping: OFF" above to cap the runaway signal, or switch to Balanced Start (1.0×).

Sanity-Checking Backpropagation: Why One Backward Sweep Beats Wiggling Weights

How can you be 100% sure Backpropagation’s Chain Rule math is not magic or slightly wrong? You can measure the exact same slope by hand!

Take one knob (w1), nudge it upward by a small wiggle, run the network forward a second time to measure the new Error, and divide how much the Error changed by how far you wiggled the knob:

(New Error - Old Error) / Wiggle Size

That hands-on verification trick is called a Numerical Gradient Check (also known as finite differences). When the wiggle is wide, a straight line connecting two far-apart points cuts across the curved Error bowl and gives a rough estimate. Shrink the wiggle until it is microscopic, and the manual wiggle estimate snaps right onto Backpropagation’s exact slope (-12.75).

So if wiggling finds the exact same slope, why does every modern AI model rely on Backpropagation instead? Because wiggling only tests one knob at a time: a model with 1 billion weights would need over 1 billion extra forward runs just to take one training step! Backpropagation (formally called Reverse-Mode Automatic Differentiation) reuses the numbers saved during a single Forward Pass to compute exact blame for all 1 billion weights simultaneously in one backward sweep.

Lab 4 starts with a rough Large Wiggle (0.50). Click Medium Wiggle (0.10) and then Tiny Wiggle (0.001) to watch the green 2-point wiggle line snap cleanly onto the purple Backprop slope!

Interactive Lab 4: Sanity-Checking Backprop by Wiggling Weight w1
Error (Loss)04812160.61.01.52.0Layer 1 Weight (w1)+0.50 wiggle-5.25 ErrorStart (w1 = 1.00)Error curve as w1 changesExact Backprop (-12.75)Wiggle Line (-10.50)
Wiggle Estimate = (New Error - Old Error) / Wiggle Size = (3.7813 - 9.0313) / 0.5 = -10.5000
Exact Backprop Slope
-12.7500
1 backward sweep for ALL weights
Manual Wiggle (+0.5)
-10.5000
Needs extra forward pass PER weight
Gap Between Estimates
2.2500
Rough! Shrink Wiggle Size
Notice the gap (2.2500)! A Large Wiggle (+0.50) draws a green line cutting straight across the curved Error bowl, giving a rough slope of -10.5000 instead of Backprop's exact -12.7500. Click "Medium Wiggle (0.10)" or "Tiny Wiggle (0.001)" above to watch the green line snap onto the purple slope!
See Vectorized Reverse-Mode Autograd, VJP & Residual Skip HighwaysThesis / Reference

1. Vectorized Backpropagation (Reverse-Mode AD, Linnainmaa, 1970; Rumelhart et al., 1986): For layer ℓ\ell with pre-activation z(ℓ)=W(ℓ)h(ℓ−1)+b(ℓ)\mathbf{z}^{(\ell)} = \mathbf{W}^{(\ell)}\mathbf{h}^{(\ell-1)} + \mathbf{b}^{(\ell)} and activation h(ℓ)=ϕ(z(ℓ))\mathbf{h}^{(\ell)} = \phi(\mathbf{z}^{(\ell)}), define the local error signal δ(ℓ)=∂L∂z(ℓ)\boldsymbol{\delta}^{(\ell)} = \frac{\partial \mathcal{L}}{\partial \mathbf{z}^{(\ell)}}. Walking backward from ℓ=L\ell = L down to 11 computes exact parameter gradients using cached forward activations:

δ(ℓ)=((W(ℓ+1))⊤δ(ℓ+1))⊙ϕ′ ⁣(z(ℓ))\boldsymbol{\delta}^{(\ell)} = \Big(\big(\mathbf{W}^{(\ell+1)}\big)^\top \boldsymbol{\delta}^{(\ell+1)}\Big) \odot \phi'\!\big(\mathbf{z}^{(\ell)}\big)
∂L∂W(ℓ)=δ(ℓ)(h(ℓ−1))⊤,∂L∂b(ℓ)=δ(ℓ)\frac{\partial \mathcal{L}}{\partial \mathbf{W}^{(\ell)}} = \boldsymbol{\delta}^{(\ell)}\big(\mathbf{h}^{(\ell-1)}\big)^\top, \qquad \frac{\partial \mathcal{L}}{\partial \mathbf{b}^{(\ell)}} = \boldsymbol{\delta}^{(\ell)}

Every backward step is a single Vector-Jacobian Product (VJP) costing roughly 2×2\times the FLOPs of the forward pass, regardless of whether the network contains 100 or 100 billion parameters (trading RAM to cache h(ℓ)\mathbf{h}^{(\ell)}, or recomputing slices via gradient checkpointing).

2. Why Residual Skip Connections Revolutionized Depth (He et al., 2016): Writing a block as h(ℓ+1)=h(ℓ)+F(h(ℓ))\mathbf{h}^{(\ell+1)} = \mathbf{h}^{(\ell)} + \mathcal{F}(\mathbf{h}^{(\ell)}) gives a backward Jacobian of I+∂F∂h(ℓ)\mathbf{I} + \frac{\partial \mathcal{F}}{\partial \mathbf{h}^{(\ell)}}. That identity term I\mathbf{I} creates an unobstructed gradient superhighway straight back to Layer 1, letting 100-layer ResNets and Transformers train without vanishing gradients!

See the Exact 5-Line PyTorch Autograd Loop (With Gradient Clipping)Optional Code
python
import torch

# Standard PyTorch training step (notice zero_grad + backward + clip + step!)
optimizer.zero_grad()                             # 1. clear old .grad buffers
preds = model(X_batch)                            # 2. Forward Pass
loss = loss_fn(preds, y_batch)                    # 3. compute scalar Loss
loss.backward()                                   # 4. Backprop (fills every .grad!)
torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0)  # prevent explosions
optimizer.step()                                  # 5. nudge weights downhill

Now that every weight has its blame score: how big a step should we take?

Backpropagation hands you the compass pointing straight uphill (so moving in the opposite direction walks downhill). Yet walking downhill on a twisted million-dimensional mountain valley is trickier than it sounds: take too small a step and training takes weeks; take too big a step and you catapult off the cliff!

That brings us straight to Gradient Descent, Learning Rate & Adam.

✓ Self-Check

Quick Intuition Check

Four quick real-world scenarios. No scores, just test your intuition.

1

During a backward pass, weight w1 receives a negative blame score (gradient) of -12.75. Which direction should the update rule nudge w1 to shrink the Error?

Pick an option first, or peek anytime
2

Why do modern AI models use Backpropagation instead of measuring every weight's slope with a Numerical Gradient Check (wiggling one weight at a time)?

Pick an option first, or peek anytime
3

While training a deep network, the blame signal snowballs across layers until numbers overflow into NaN ('Not a Number'). Which safeguard directly caps runaway blame before it wrecks the weights?

Pick an option first, or peek anytime
4

Backpropagation changes the network's weights automatically during the backward sweep, so no separate weight-update step is needed.

Pick an option first, or peek anytime
Quick Reference

Common Questions

How does backpropagation work in a neural network?
Backpropagation runs in two passes. First, a forward pass computes each layer's activations and the final prediction loss. Second, a backward pass applies the chain rule from the output layer back to the input layer, computing the exact gradient (how much each weight contributed to the error) so an optimizer like SGD or Adam can update every weight.
What does Backpropagation actually do in a neural network?
Backpropagation computes the exact gradient (dLoss/dw) of the loss function with respect to every weight and bias in the network by applying the Chain Rule backward from the final loss to the earliest layer. It tells the optimizer which direction to nudge each weight to shrink the mistake.
What is the difference between Backpropagation and Gradient Descent?
Backpropagation is the accounting step that calculates the gradients (how much each weight is to blame for the error). Gradient Descent (or Adam) is the action step that actually updates the weights using those gradients and a learning rate.
Why is Backpropagation so much faster than wiggling each weight one by one?
Testing every weight individually via finite differences would require two full forward passes per parameter (2 billion passes for a 1B-parameter model!). Reverse-mode Backpropagation reuses cached intermediate activations from a single forward pass to compute ALL gradients simultaneously in one backward pass.
What causes Exploding Gradients and how do engineers stop them?
If layer derivatives repeatedly exceed 1.0 across a deep stack or long sequence, their product snowballs exponentially until weights overflow into NaN. Engineers stop exploding gradients with He/Xavier initialization, Layer/Batch Normalization, Residual Skip Connections, and Gradient Clipping (clip_grad_norm_).
Why do you have to call optimizer.zero_grad() in PyTorch before loss.backward()?
PyTorch accumulates (adds) newly computed gradients onto existing .grad buffers by default so engineers can simulate larger batches via gradient accumulation. Forgetting optimizer.zero_grad() mixes stale gradients from previous batches into the current update and corrupts training.

Written & illustrated by Muhammad Aashir Irshad · Updated December 2026 · Free open-access reference

https://seeingml.com/learn/backpropagation/ Open GitHub issue Suggest an edit
Cite this guide in a paper, thesis, or course (BibTeX & APA)
BibTeX
@misc{irshad2026backpropagation,
  author       = {Irshad, Muhammad Aashir},
  title        = {Backpropagation: Interactive Visual Guide},
  howpublished = {SeeingML},
  year         = {2026},
  month        = {dec},
  url          = {https://seeingml.com/learn/backpropagation/},
  note         = {Interactive visual guide}
}
APA

Irshad, M. A. (2026). Backpropagation: Interactive Visual Guide. SeeingML. https://seeingml.com/learn/backpropagation/