Backprop Bulletin explainer
What is gradient descent?
Gradient descent adjusts the weights of a model to reduce its loss. At the current weights, the gradient points in the direction where loss increases fastest. Gradient descent takes a step in the opposite direction. The learning rate scales that step.
Start with a prediction of 2
Take an input of 2 and multiply it by two weights in turn. The first weight, w₁, is 0.5. The second, w₂, is 2. The prediction is 2 × 0.5 × 2 = 2. The target is 3, so the squared error, our loss, is (2 − 3)² = 1.
At these weights, backpropagation gives a gradient of −8 for the first weight and −2 for the second. Both slopes are negative. Increasing either weight a little, while holding the other fixed, brings the prediction closer to 3.
One step at two learning rates
For each weight, subtract the learning rate times its gradient. Update both weights together. Each column below starts over at the same weights (0.5 and 2) and uses the same gradients (−8 and −2).
| Learning rate | 0.025 | 0.1 |
|---|---|---|
| New w₁ | 0.7 | 1.3 |
| New w₂ | 2.05 | 2.2 |
| Prediction | 2.87 | 5.72 |
| Squared loss | 0.0169 | 7.3984 |
At 0.025, the first weight increases by 0.025 × 8 = 0.2 and the second by 0.025 × 2 = 0.05. The new prediction is 2 × 0.7 × 2.05 = 2.87. It falls short by just 0.13, so the loss drops from 1 to 0.0169.
At 0.1, both updates are four times as large. The new prediction is 2 × 1.3 × 2.2 = 5.72. It overshoots the target by 2.72, a bigger miss than the original error of 1. Squaring that miss gives a loss of 7.3984.
What changes on the next step?
A gradient measures the slope where you started. Here, moving a short distance against it lowers the loss. Farther along the same line the prediction passes 3, and the loss starts rising again. On the next training step, recompute the prediction and gradients at the new weights. After the overshoot, increasing either weight would push the prediction even farther above the target.