Before you readA hidden neuron feeds two outputs. If raising one output increases the loss and raising the other decreases it, can you tell whether to raise the hidden neuron’s value?
Watch: What is backpropagation really doing? · 3Blue1Brown · Neural networks, ch. 3
The forward pass computes a prediction and a loss. Backpropagation goes the other way: for each intermediate value, it finds how much the loss would change if that value increased a little. Over one edge, multiply the gradient coming back by the edge’s local derivative. Where several paths lead to the loss, add their contributions.
Take x=2,z=wx and h=ReLU(z). Let h feed two outputs u=2h and v=−h, with targets 0 and 1. Their squared-error loss is L=21[u2+(v−1)2]. The two output gradients are ∂L/∂u=u and ∂L/∂v=v−1, so the gradient at h is
∂h∂L=u⋅2+(v−1)⋅(−1).
At w=1,h=2. The output gradients 4 and −3 have opposite signs, but their contributions at h are 8 and 3: increasing h moves both outputs away from their targets. Follow the arrows back from the loss to see where the sum is formed.
∂L/∂h=8+3=11∂L/∂w=22
Read right to left. The two paths meet at h, where their gradients add. Move w below zero to see the ReLU block the gradient.
Recall
When a value affects the loss along two paths, which derivatives do you multiply and which do you add?
To get the gradient for w, continue backward:
∂w∂L=∂h∂LReLU′(z)x.
For z>0 the ReLU passes the gradient back unchanged; for z<0 it blocks it. At z=0 the derivative is undefined; implementations typically use zero there. Backprop computes each intermediate gradient once and reuses it for all values that feed into it. It computes gradients; it doesn’t update weights.
Recall
What does a ReLU with negative input send back to its incoming weights for this example?
Exercise
In the two-output network above, set w=21 and keep x=2. Find ∂L/∂h and ∂L/∂w, in that order.
Exercise
Now set w=−21, still with x=2. Find ∂L/∂h and ∂L/∂w, in that order.