Skip to content

Backpropagation Computes Gradients Without Updating Weights

Backpropagation is the method that computes the gradient of a loss with respect to every weight in a network, by applying the chain rule backward from the output to the inputs. That is all it does. Goodfellow, Bengio, and Courville say that the term "is often misunderstood as meaning the whole learning algorithm for multi-layer neural networks. Actually, back-propagation refers only to the method for computing the gradient, while another algorithm, such as stochastic gradient descent, is used to perform learning using this gradient." They also describe it as "an algorithm that computes the chain rule, with a specific order of operations that is highly efficient."

The chain rule says that if y = g(x) and z = f(y), then dz/dx = (dz/dy)(dy/dx). A network is a chain of such steps, so the gradient for an early weight is a product of local derivatives collected on the way back from the loss.

Try it by hand. Take a tiny network with one input x = 2 and two weights, w₁ = 0.5 and w₂ = 3. It computes a = w₁x, then h = ReLU(a), then ŷ = w₂h, and the loss against a target of 5 is L = (ŷ − 5)². Forward pass: a = 1, h = 1, ŷ = 3, L = 4. Now go backward, one local derivative at a time. dL/dŷ = 2(ŷ − 5) = −4. Then dL/dw₂ = (dL/dŷ) × h = −4 × 1 = −4, and dL/dh = (dL/dŷ) × w₂ = −4 × 3 = −12. The ReLU has slope 1 at a = 1, so dL/da = −12. Finally dL/dw₁ = (dL/da) × x = −12 × 2 = −24. A numerical check agrees: nudging w₁ and w₂ by a tiny amount in each direction gives slopes of −24.000 and −4.000. Everything so far was backpropagation, and no weight has changed.

Learning is the next step, and it belongs to the optimizer. With a learning rate of 0.01, gradient descent sets each weight to its old value minus 0.01 times its gradient: w₁ = 0.5 + 0.24 = 0.74 and w₂ = 3 + 0.04 = 3.04. The new forward pass gives a = 1.48, ŷ = 4.4992, and a loss of about 0.25, down from 4. Swap in a different optimizer and the same backpropagation feeds it.

The book adds that backpropagation is not specific to multi-layer networks. In principle it can compute derivatives of any function, and for some functions the right answer is that the derivative is undefined. When branches of the computation meet, their contributions to a gradient add.

The trap: calling backpropagation the optimizer, or thinking it sends the target values backward through the network. What travels backward are derivatives of the loss, and they change nothing until an optimizer uses them.

Prof Rod's rule: backpropagation answers "which way is downhill?" and the optimizer decides how far to step.

The network, target, and learning rate are invented for the example.

Goodfellow, Bengio, and Courville, Deep Learning, MIT Press, 2016, Section 6.5 (p. 199) and Section 6.5.2 Chain Rule of Calculus (p. 200)