Chapter 3

Backprop, one operation at a time

In chapter 1, one click on Backward gave every weight its gradient. This chapter opens up that click. Inside, it is nothing more than multiplying small numbers, one operation at a time.

What this is

This film follows backpropagation through a single neuron, like chapter 2's but with a bias, one operation at a time. The rest of the page explains each step, then hands you the controls.

Chapter 1 showed what training does: guess, measure, adjust. Chapter 2 showed what the adjusting needs: one slope per weight, together called the gradient, which points uphill on the loss landscape so training can step the other way. In chapter 1 the Backward stage produced every one of those slopes at once. This chapter shows how. If you skipped the earlier chapters, the film and the next section are enough to follow along.

The question

A gradient answers one question: if I nudge this parameter up a little, how much does the loss change? (A network's parameters are its weights and biases; chapter 1's network has 17.) There is an obvious way to find out. Nudge the parameter, run the network again, and measure. That works, and the playground below uses it to double-check every answer. But it costs one extra run of the network for every single parameter, or two if you nudge both ways as the playground does.

Number of parameters17
Nudge each weight
Backpropagation

Backpropagation gets every gradient for about the cost of three runs, however many parameters there are: one forward pass, then a backward pass that costs about two more. That one trick, more than any other, is why large networks can be trained at all. It is built from three simple tools.

Tool 1: the slope of one operation

Chapter 2 measured slopes by nudging the whole network. Backpropagation instead uses the slope of each small operation, which is always easy to know. Start with one operation on its own, such as tanh. Its slope at a point says how much the output moves when you nudge the input. A slope of 0.5 means a nudge of 0.01 in the input moves the output by about 0.005. Drag across the curve to see the slope change.

drag across the curve

Every operation in a network has a simple slope rule. These six cover everything on this page:

OperationSlopeIn words
a + b1 and 1A nudge to either input passes straight through.
a × bb and aEach input's slope is the other input.
tanh(a)1 − tanh(a)²Steep near 0, flat far away.
σ(a)σ(a)·(1 − σ(a))Steepest at a = 0, where σ = 0.5; flat when σ is near 0 or 1.
−log(a)−1 / aVery steep when a is close to 0.
a²2aGrows with a; zero at a = 0.

These are called local slopes, because each one looks only at its own inputs and output, and nothing else in the network.

Tool 2: the chain rule

Operations come in chains. If y moves 3 times as much as x, and z moves 0.5 times as much as y, then z moves 3 × 0.5 = 1.5 times as much as x. Slopes along a chain multiply, the same way exchange rates do: if 1 yen buys 0.007 dollars and 1 dollar buys 0.9 euros, then 1 yen buys 0.007 × 0.9 euros.

×3slope 3 tanh ×2slope 2

That is the whole chain rule. Backpropagation applies it to every path through the network at once, and reuses shared work, so nothing is computed twice.

Tool 3: the graph, three rules, and a tape

Any calculation can be drawn as a graph: numbers flow along wires into small operations. The film's neuron is six operations. Chapter 1's network, for a single dot, is about thirty. Backpropagation walks that graph backward with three rules:

  1. Start with 1 at the loss. Nudge L by a little and L changes by exactly that much, so ∂L/∂L = 1.
  2. Multiply and pass back. Each operation takes the gradient it has received, multiplies it by its local slope for each input, and sends the result to that input.
  3. Add what arrives. If a value is used in several places, its gradient is the sum of everything that comes back to it.

To walk backward you need to know the order things happened in. So during the forward pass, every operation writes itself onto a list called the tape. The backward pass reads the tape in reverse. Here is the complete algorithm in six short parts. Choose how you want it explained: in words, in math, or as code. The code is the JavaScript this site runs, or the same program in Python; the last part shows the same calculation in PyTorch. Chapters 1 and 2 fused σ and the loss into one step; here they stay separate so you can watch each.

The playground

Pick a graph and press Step. Each click does exactly one thing: one operation forward, or one operation's backward rule. The box below the graph says what happened, in words, in numbers and in code. Tap any starting number to change it, and use Nudge test to check autograd's answer the slow way.

Graph
Step through
Show

#ValueOperationResultLocal slopesGradient

How to read the figure

Boxes
Starting numbers. A solid box is a weight the network learns. A dashed box is an input, which gets a gradient too but is never changed by training.
Circles
Operations. The number under each circle is its result from the forward pass.
Gradient tags
The colored tag above a node is its gradient, ∂L/∂(that node): blue for a positive gradient, orange for a negative one. (Chapter 1's backward view colors the direction each weight should move, which is the opposite sign.)
Slope tags
“×0.20” on a wire is the local slope the backward pass multiplies by when it sends a gradient back along that wire.
Moving dots
Forward, values flow to the right. Backward, gradients flow to the left.
The tape
The table under the graph: every operation in the order it ran. The forward pass fills it top to bottom; the backward pass works up from the bottom.

Things to try

What runs where

Everything runs in this page's JavaScript on your CPU, in 64-bit floats. The playground builds every graph with the code shown above. The Python shown beside it is a line-by-line translation of the same program, and the PyTorch example computes the playground's neuron with a real library. Its Step button runs backward() one tape entry per click, after a first click that sets ∂L/∂L = 1. The nudge test compares the real backward() with a measured slope, (L(x + ε) − L(x − ε)) / 2ε with ε = 0.0001.

Where this is going

  1. 1A network you can touch
  2. 2Loss and gradients: walking downhill
  3. 3Backprop, one operation at a timeThis page
  4. 4Going deeper: why layers help
  5. 5Seeing: convolutional networks
  6. 5′Listening: spectrograms and soundBranch
  7. 6Words as vectors: tokens and embeddings
  8. 7Attention: looking back over the whole story
  9. 8A tiny GPT, trained in your browser

Working prototype, October 2026. Every figure on this page is a live computation.
Source on GitHub · code under MIT, text and figures under CC BY 4.0.