3Blue1Brown neural networks ch. 4: backpropagation calculus — notes

Updated 2026-10-02 · Video: 3Blue1Brown, published 2017-11-03 · 10 min

Watch the video (10 min)

Watch the original video on YouTube

Chapter 4 turns the intuitive walkthrough of chapter 3 into formulas. It starts with a toy network that has one neuron per layer, uses the chain rule to get the cost’s sensitivity to one weight, then adds indices for full layers. The video assumes you watched chapter 3 and are comfortable with derivatives and the chain rule. It is the most formula-dense video in the series and the one that best repays pausing. Optional for viewers who only want the intuition; essential if you plan to implement backprop yourself.

Key takeaways

  1. Name the weighted sum z. Then each weight affects the cost through a chain: w → z → a → C (1:38).
  2. ∂C/∂w is a product of three local derivatives: a(L−1), σ′(z(L)) and 2(a(L) − y) (4:03).
  3. The bias formula is almost the same, with ∂z/∂b = 1 in place of a(L−1) (5:11).
  4. ∂z/∂a(L−1) = w(L) is what makes it backpropagation. It hands the sensitivity to the previous layer so the same step can repeat (5:11).
  5. With many neurons, an earlier activation’s derivative is a sum over paths. Everything else is extra indices (8:28).

Chapter notes

0:00 – 0:34 Goal: how ML people think about the chain rule

Grant states the aim: show how the chain rule is used in networks, which “has a different feel” from a typical calculus course. The difference is that in networks you track sensitivities flowing through a graph of simple operations, rather than differentiating one big closed-form expression.

0:34 – 1:38 The one-neuron-per-layer network

The simplest possible case: four neurons in a row, three weights, three biases. Focus on the last link. Call the last activation a(L) and the one before it a(L−1). The superscripts index layers; they are not powers. For a target y, the cost of one example is C₀ = (a(L) − y)².

Chain of single neurons ending in a(L−1) and a(L), with desired output y = 1.00 and the cost C0 = (a(L) − y)², for example (0.66 − 1.00)²
1:38 — The toy setup. One output, one target, one squared error. Every formula in the video is first derived on this picture.

1:38 – 3:44 Naming z and drawing the dependency chain

The last activation is a(L) = σ(w(L)·a(L−1) + b(L)). Grant names the inside z(L) = w(L)·a(L−1) + b(L). This one step makes the rest readable. Now the dependencies form a small tree: w, a(L−1) and b feed z; z feeds a; a and y feed C.

Computational graph with w(L), a(L−1) and b(L) feeding z(L), which feeds a(L), which with y feeds C0, each on its own small number line, beside the chain rule ∂C0/∂w(L) = ∂z/∂w · ∂a/∂z · ∂C0/∂a
3:44 — The computational graph with a number line for each quantity. A nudge to w moves z, which moves a, which moves C. Multiply the three ratios to get ∂C₀/∂w(L).

The number-line picture is the best part of the video. Read ∂w as “a tiny nudge, like 0.01” and ∂C as “the resulting nudge to the cost.” Then the chain rule is just the claim that ratios multiply along the chain. It is the same “desired nudge” language as chapter 3, now made exact.

3:44 – 4:49 Computing each factor

Each of the three factors is easy on its own:

  • ∂C₀/∂a(L) = 2(a(L) − y). It is large when the output is far from the target, so badly wrong outputs drive the biggest updates.
  • ∂a(L)/∂z(L) = σ′(z(L)), the slope of the nonlinearity at the current input.
  • ∂z(L)/∂w(L) = a(L−1), the previous activation.
The three derivatives listed: ∂C0/∂a(L) = 2(a(L) − y), ∂a(L)/∂z(L) = σ′(z(L)), ∂z(L)/∂w(L) = a(L−1), beside the definitions of C0, z(L) and a(L)
4:49 — The three local derivatives. Each one depends only on values already computed in the forward pass. That is why backprop is cheap.

Grant asks you to stop and interpret the last factor. A weight’s influence scales with how active the previous neuron is, which is “fire together, wire together” from chapter 3 written as math.

4:49 – 6:43 Assembling, then bias and previous activation

Multiplying gives ∂C₀/∂w(L) = a(L−1) · σ′(z(L)) · 2(a(L) − y). That covers one example only. The full cost averages over all examples, so its derivative averages this expression. And it is just one of the 13,002 entries of the gradient.

Assembled formula ∂C0/∂w(L) = a(L−1) σ′(z(L)) 2(a(L) − y), with ∂Ck/∂w(L) shown below to indicate one term per training example k
5:11 — The finished derivative for one weight and one example. The subscript k on Cₖ is a reminder that you compute this per example and average.

Two variants follow with almost no extra work. For the bias, swap ∂z/∂w for ∂z/∂b, which is 1. For the previous activation, swap in ∂z/∂a(L−1) = w(L). That last one is the hinge of the whole algorithm. You cannot change a(L−1) directly, but knowing ∂C/∂a(L−1) lets you treat layer L−1 as if it were the output and repeat the same three-factor step for w(L−1) and b(L−1).

A practical pitfall: the factor σ′(z) appears once per layer. With a sigmoid, σ′ is at most 0.25 and near zero when the neuron is saturated. Multiply several of these and gradients for early layers shrink. This is one concrete reason chapter 1’s closing interview favors ReLU.

6:43 – 8:28 Many neurons per layer

Real layers have many neurons, so add subscripts. Let k index neurons in layer L−1 and j index neurons in layer L. The cost becomes a sum over outputs: C₀ = Σⱼ (aⱼ(L) − yⱼ)².

Small network with three neurons in layer L−1 labelled a0, a1, a2 with superscript L−1 and two neurons in layer L labelled a0 and a1 with superscript L
7:03 — Subscripts added: k counts neurons in the earlier layer, j in the later one. The superscript still names the layer.

The weight from neuron k to neuron j is wjk(L). The order looks backwards, target first, but it matches the weight matrix from chapter 1, where row j holds the weights into neuron j. With z and a defined per neuron, the derivative for one weight has the same three-factor shape as before.

Chain rule for one indexed weight, ∂C0/∂w_jk(L) = ∂z_j/∂w_jk · ∂a_j/∂z_j · ∂C0/∂a_j, next to the definitions z_j(L) = ... + w_jk(L) a_k(L−1) + ..., a_j(L) = σ(z_j(L)), and the summed cost
8:13 — The indexed version. Once you check that each factor refers to one specific neuron, it is the same formula as at 5:11.

8:28 – 9:24 The one real change: summing over paths

What does change is the derivative with respect to an earlier activation. Neuron k in layer L−1 feeds every neuron in layer L, and each of those affects the cost. So its influence is the sum of the chain-rule products along each path.

Formula ∂C0/∂a_k(L−1) = sum over j of ∂z_j/∂a_k · ∂a_j/∂z_j · ∂C0/∂a_j, with neuron a_k(L−1) connected to both a0(L) and a1(L)
8:28 — One earlier neuron, several routes to the cost. The sum over j is the exact version of chapter 3's "add up every output neuron's wishes."

This sum is the precise form of the averaging-of-wishes step at 7:35 in chapter 3. With it, you know ∂C/∂a for every neuron in layer L−1 and can repeat the process all the way to the input.

9:24 – 10:17 The full recipe in one box

The closing slide packs everything into two lines.

Summary formula: ∂C/∂w_jk(l) = a_k(l−1) σ′(z_j(l)) ∂C/∂a_j(l), where ∂C/∂a_j(l) is either a sum over the next layer of w σ′(z) ∂C/∂a(l+1), or 2(a_j(L) − y_j) for the output layer
9:24 — The whole of backprop: weight gradient = previous activation × σ′ × activation gradient. The activation gradient comes from the next layer (the sum) or, at the output, from the cost (2(a − y)).

A reading tip for this slide: inside the sum, j runs over neurons in layer l+1, so it is a different j from the one on the left. Read it as “sum over every neuron in the next layer that this neuron feeds.” Libraries vectorize the same recipe with matrices: the sum over j becomes a multiplication by the transposed weight matrix. Grant ends by acknowledging it is “a lot of layers of complexity” and that it is normal to need time.

Skip list

  • 0:17 – 0:34 Pause-and-ponder reminder and the calculus series plug.
  • 6:43 – 7:03 The “isn’t this oversimplified?” setup. The answer arrives right after.
  • 9:37 – 10:17 Closing reassurance and Patreon credits.

Glossary

  • Chain rule — the derivative of a composition is the product of the derivatives of each step.
  • z (weighted sum) — w·a + b before the nonlinearity; naming it splits the chain into simple pieces.
  • σ′(z) — the slope of the activation function at the neuron’s current input.
  • Partial derivative ∂C/∂w — how much the cost changes per tiny change in one parameter, holding the rest fixed.
  • wjk — the weight from neuron k in the earlier layer to neuron j in the later layer.
  • Computational graph — the diagram of which quantities feed which; backprop walks it in reverse.
  • Vanishing gradient — the shrinking of early-layer gradients when many small σ′ factors multiply together.

FAQ

What is the formula for the derivative of the cost with respect to a weight?

For a single training example, ∂C/∂w = a(L−1) · σ′(z(L)) · 2(a(L) − y) in the one-neuron case. It is the product of three chain-rule factors: how z depends on w, how a depends on z, and how the cost depends on a.

How does backpropagation use the chain rule?

Each weight affects the cost through a chain: weight to weighted sum z, z to activation a, a to cost. Multiplying the local derivatives along that chain gives the weight's sensitivity, and the derivative with respect to an earlier activation lets you repeat the same step one layer back.

What changes when layers have more than one neuron?

Mostly the indices: weights become w_jk, linking neuron k in layer L−1 to neuron j in layer L. The one real change is that an earlier activation affects the cost through several neurons in the next layer, so its derivative is a sum over those paths.

What is the derivative with respect to the bias?

It is the same chain as for the weight, except ∂z/∂b = 1 replaces ∂z/∂w = a(L−1). So ∂C/∂b = σ′(z(L)) · 2(a(L) − y) for one example in the simple network.

Studying another course? Paste its YouTube or Bilibili link on the home page to request a handout — or make your own with the desktop app (coming soon).

Updated 2026-10-02 · By Yao

Not affiliated with the creators, universities or companies whose videos are covered here. Videos belong to their creators; this site only adds commentary.

Sources & credits

How these notes were made

A human watched the full video and wrote these notes with AI assistance for drafting. Stills are limited to a handful of frames used for commentary, each linked to its timestamp; no transcript is reproduced. Spot an error? Let us know via the contact page.