Backpropagation and the chain rule
What it is
Backpropagation applies the chain rule from the scalar loss backward through the computation graph. Each operation receives the gradient of the loss with respect to its output, combines it with its own local derivative, and returns gradients for its inputs and parameters. The forward pass stores the intermediate values required by those local derivatives; the backward pass then visits operations in reverse dependency order. In PyTorch, loss.backward() performs this traversal and accumulates the resulting tensors into every parameter's .grad field.
Why it matters
It makes training networks with millions of parameters feasible: derivatives are reused locally instead of recomputing one full derivative per parameter. It also gives a useful debugging boundary: if loss is finite but gradients are missing, zero, NaN, or attached to unexpected parameters, the computation graph or objective is wrong before the optimiser is ever involved.
In the real world: How a speech model learns which parts of itself caused a mis-heard word.
Visual example
Deep learningThe forward computation runs left to right; gradient information runs from loss back to every parameter.
optimizer.zero_grad() # gradients accumulate by default
loss = loss_fn(model(x), y)
loss.backward() # fills parameter.grad
optimizer.step() # applies the updateForgetting zero_grad(). PyTorch accumulates gradients intentionally for gradient accumulation; without a deliberate accumulation plan, stale gradients silently change the effective update.
Practise it: ReLU, Forward and Backward, Linear Layer Forward and Backward, Layer Norm, Backwards