Here you get to see how a neural network actually learns. We follow a single training example all the way round: the network guesses, we measure how wrong the guess was, the error is sent backwards through the network, and every weight is nudged a little.
Pick a logic gate. The network has to learn to give the right answer for all four combinations of the inputs x₁ and x₂.
Follow the network as it learns, step by step, from a random guess to a fully trained model.
SvenskaBackpropagation is the method that works out how each weight should change so the network guesses better next time.
Once the network has made its guess, we first work out how large the error was. Then we work backwards through the network. Starting at the output, we ask:
In the end every weight knows how much influence it had on the error. That number is called the error signal.
To decide how much a weight contributed to the error we use derivatives. A derivative answers the question:
At every calculation step z (the neuron's weighted sum), a (the neuron's activation, the sum after sigmoid), ŷ (the network's guess) and L (the loss, how wrong the guess was) are concrete numbers, worked out for a given input and given weights. What gets differentiated is not those individual numbers but the relationship between them. Hold every other value fixed and let w vary, and a curve appears – the derivative is the slope of that curve at exactly the point where the weight currently sits. Not the height, but how steep it is there.
A weight does not affect the error directly. It first affects the next neuron, that neuron affects the next, and finally the network's output, which in turn affects the loss.
To work out how much the weight affects the loss we have to account for every step in the chain. That is why the local slopes are multiplied together:
Each link in the chain has its own ready-made formula. The notation ∂A/∂B reads: how much A changes when B is nudged slightly.
The chain rule multiplies these slopes together, step by step backwards through the network – which is exactly what Phase 3 · Backprop does, and why the signal travels backwards: the forward pass works out the network's answer, backpropagation works out the responsibility for the error.
The result for a weight is called its gradient, and it tells us two things:
The steeper the curve, the more sensitive the loss is to changes in the weight. Right at the bottom of the valley the slope is zero – there is no way to reduce the loss further by moving the weight in either direction. So the loss is at its smallest at the bottom of the curve.
Letting every weight take one small step down its own curve, in the opposite direction to the gradient, and repeating that round after round, is called gradient descent. That is exactly what happens in Phase 4 · Update weights, and it is how the network slowly works its way down towards the bottom of the valley.