Visual explainer
Gradient Descent
Follow computed parameter updates, compare learning rates, and see why a downhill direction can still produce a worse finite step.
Gradient descent changes parameters by subtracting a learning rate times the loss gradient. The direction is local; whether a finite step helps depends on its size and the objective.
Our synthetic objective is . At parameter , loss is 4. Horizontal position is the parameter; vertical height is loss. The full curve is shown so we can check the result. An optimizer need not know the whole curve before computing a local update. The gradient-descent chapter in Dive into Deep Learning derives the method and discusses learning-rate failures.
Read The Local Slope
The derivative is , so at 2 it is . The dashed tangent is and touches the curve at . Increasing locally increases loss; a small movement toward smaller decreases it.
The tangent's screen angle also depends on axis scaling. A derivative of 4 is loss units per parameter unit, not a four-pixel rise. At a stationary point the gradient is zero and supplies no nonzero direction.
Subtract A Scaled Gradient
The update is . With illustrative learning rate , it gives . The circle marks the old parameter and the diamond the next one; the bracket measures a displacement of magnitude 1. This is a parameter numberline, rather than another loss-height plot.
Evaluate the objective again: loss changes from to . The displacement is 1, while the loss reduction is 3. They are different quantities.
Repeat The Update
For this objective and this learning rate, . The three aligned numberlines show , and . Circles mark starting values, diamonds mark endpoints, and highlighted intervals measure step magnitudes 1, 0.5 and 0.25. All rows use the same scale.
The shrinking intervals follow this recurrence. They are not a universal property of gradient descent. The iterates approach zero asymptotically in exact arithmetic; they do not reach it after these three updates.
Check Loss After Updating
There are four states including the initial one, but only three updates. At update indices 0, 1, 2 and 3, loss is . The bars retain the earlier zero-based loss scale. The last bar is truly tiny; its height is not enlarged for visibility.
This particular sequence reduces loss by a factor of 64. Its computed behavior does not guarantee the same reduction for a different model, objective or learning rate.
Compare Two Learning Rates
The vertical axis now shows parameter , and the horizontal axis counts updates. Starting at 2, gives , marked by circles. Changing only the rate to 1 gives , marked by diamonds and a dashed trace. Both runs share the initial point. Joins only connect discrete iterates.
For , convergence from a nonzero start requires , or . Rates between 0.5 and 1 cross zero while their magnitudes shrink; oscillation does not always mean divergence. At , loss stays 4. These thresholds belong to this quadratic, so 0.25 is not a general starting recommendation.
Zero Slope Can Mislead
Change the objective explicitly to a differentiable plateau example: loss is 1 for , for , and 0 for . The middle derivative is zero at both joins. The drawing is an exact plot with a new vertical scale.
At , loss is 1 and its derivative is exactly zero. Vanilla gradient descent stays there for any finite learning rate, even though a lower plateau exists to the right. A zero-gradient check alone cannot distinguish this flat region from a desired solution. This constructed example demonstrates the limit, rather than predicting how often it happens in training.
Update Two Parameters
Now use . These are parameter-space contours: an ellipse labeled 6 contains points of loss 6, and the ellipse labeled 1 contains points of loss 1. Both axes use the same parameter scale. The origin is the shared center.
At start , the gradient is . Using gives , reducing loss from 6 to 1. The dotted component projections and diagonal arrow show the move. It crosses contours; it does not follow a path on a drawn loss-height surface. The negative gradient is the local steepest-descent direction in Euclidean parameter geometry.
Objective Scale Matters
Switch to a one-dimensional comparison at and hold fixed. For , the gradient is 2 and the displacement is . For , it is 20 and the displacement is . The shared ruler measures distance to the left from zero displacement; the two arrows use identical scales.
The minimizer stays at zero, but the second update jumps from 1 to instead of 0.8. Multiplying an objective by a positive constant changes the effective learning rate for plain gradient descent. Reduction conventions and target units therefore matter when transferring a learning rate.
Where It Breaks
Return to and start , but set . The recurrence becomes : parameters go and losses go . The final loss plot uses an explicitly expanded 0–22 range, with a common zero baseline. No endpoint is clipped.
Each update subtracts the correct local gradient, but overshoots so far that it raises loss. This is a finite-step failure, rather than a gradient-sign error. Monitor the objective and choose step size for its scale and curvature. Even a decreasing training objective still needs separate generalization evaluation.
The Quick Version
- Compute the gradient at the current parameter.
- Subtract learning rate times gradient, then evaluate again.
- Three quadratic updates give four states, including the initial state.
- Objective scaling changes plain gradient descent's effective step size.
- Zero gradient can occur above a better solution.
- Correct local direction does not guarantee a good finite step.