Every modern neural network is trained by some variant of one idea: compute which way the loss decreases fastest and take a small step that way. This lesson covers why that works, how the step size and the curvature of the loss interact, and what the loss surfaces of large networks look like in practice.
The update
Given a differentiable loss over parameters , gradient descent repeats
where is the learning rate. Textbooks usually credit the method to Augustin-Louis Cauchy, who described it in a note to the Paris Académie des Sciences in 1847. Historians point out that his note is less clear-cut than the textbook version.[1]
Why the negative gradient? A first-order Taylor expansion gives . Among all steps of a fixed small length, is most negative when points along (by the Cauchy–Schwarz inequality). The gradient is the direction of steepest local increase, and we go the other way.
Curvature sets the speed limit
The first-order picture says nothing about how large a step can be. Adding the second-order term shows what goes wrong:
where and is the Hessian, the matrix of second derivatives. The linear term always helps. The quadratic term hurts in proportion to the curvature along the step direction. If the step is too large, the curvature term wins and the loss goes up.
One dimension
Take , with curvature . Then and the update is
The iterate shrinks geometrically when , that is, when . For it approaches the minimum smoothly. For it overshoots and oscillates while still converging. For it diverges. The highest curvature you encounter sets the largest stable learning rate.
Many dimensions and the condition number
Near a minimum, any smooth loss looks like a quadratic . In the eigenbasis of , gradient descent splits into independent one-dimensional problems, one per eigenvalue , each contracting by per step. The learning rate must satisfy for stability, but progress along the flattest direction is governed by . The ratio is the condition number. With the best fixed step, , the error contracts by a factor of per step.
Worked example: a long, narrow valley
Let . The curvatures are 1 and 100, so .
- Stability requires .
- The best fixed step is , and the contraction factor is .
- Reducing the error by a factor of 100 then takes about steps.
The steep direction forces a small step size, and the shallow direction then takes hundreds of steps to make progress. The iterates zig-zag across the valley while creeping along it. A perfectly round bowl () would be solved in one step. Poor conditioning, not distance from the minimum, is what makes plain gradient descent slow. It is the main motivation for momentum and adaptive methods, covered in Stochastic optimization.
For , you choose . What happens?
Show answer +Hide answer −
Along , the contraction factor is , which has magnitude greater than 1. The coordinate flips sign and grows by 50% each step, so the iteration diverges, even though the direction alone would be perfectly happy with this step size.
What neural-network loss surfaces look like
A quadratic bowl is a local picture. The full loss of a deep network is non-convex, high-dimensional and shaped by symmetries; for example, permuting the hidden units of a layer leaves the function unchanged. A few facts hold up across the literature:
- Saddle points outnumber bad local minima. At a critical point in very high dimension, it is unlikely that the curvature is positive in every one of millions of directions. Dauphin et al. argued, drawing on random-matrix theory and experiments, that the main obstacle is saddle points and the flat plateaus around them, which can look like local minima. High-error local minima are less of a problem.[2] Gradient descent slows near saddles but is not trapped by them, and the noise of stochastic gradients helps it leave.
- Many minima, connected. Overparameterised networks have large sets of parameters that fit the training data equally well. Which one the optimiser lands in depends on initialisation, learning rate and batch size. This matters for generalization (see Generalization).
- Training runs at the edge of stability. The quadratic analysis predicts divergence once the sharpness exceeds . Cohen et al. found that full-batch gradient descent on neural networks typically pushes sharpness up until it hovers just above . The loss then decreases non-monotonically over short timescales while still falling over long ones.[3] The network adapts its curvature to the learning rate rather than the other way round. The classical stability bound is still the right reference point, but it does not describe what happens next.
Edge-of-stability training sits at sharpness . If you halve the learning rate partway through training, what does the classical analysis predict, and what would you expect to happen to sharpness afterwards?
Show answer +Hide answer −
At the new step size the stability threshold doubles to , so the current curvature is comfortably stable and the loss should drop smoothly at first. If the edge-of-stability pattern holds, sharpness will then rise again toward the new threshold . The temporary room below the stability threshold is one plausible account of the quick fall in loss often seen right after a learning-rate decay.
Practical consequences
Several standard training practices follow from the curvature picture:
- Learning-rate warmup. Early in training, before the parameters have settled into well-scaled values, a large step is more likely to diverge. Starting with a small step and raising it over the first few thousand updates avoids early divergence. Large-batch training relies on warmup explicitly,[4] and large language models routinely use it. Llama 2, for instance, used 2,000 warmup steps followed by cosine decay.[5]
- Decay. Lowering the step later lets the iterate settle into regions of higher curvature that a large step would bounce out of.
- Gradient clipping. Capping the gradient norm limits the damage from a single step taken where the local curvature or gradient spikes.
- Normalisation and residual connections improve conditioning, so a single learning rate suits more directions at once.
Key takeaways
- Gradient descent steps along , the direction of steepest local decrease. Its use for optimisation goes back to Cauchy in 1847.
- On a quadratic, stability requires , and the convergence rate is governed by the condition number . With , a 100-fold reduction takes about 230 steps.
- Deep-network losses are non-convex, with saddle points and plateaus as the main obstacles and many equally good minima.
- In practice sharpness tends to settle near (the edge of stability). Warmup, decay and clipping are ways of managing curvature.
Sources
-
C. Lemaréchal (2012). "Cauchy and the Gradient Method." Documenta Mathematica, Extra Volume: Optimization Stories, 251–254. https://doi.org/10.4171/DMS/6/27 ↩
-
Y. Dauphin, R. Pascanu, C. Gulcehre, K. Cho, S. Ganguli and Y. Bengio (2014). "Identifying and attacking the saddle point problem in high-dimensional non-convex optimization." arXiv:1406.2572. https://arxiv.org/abs/1406.2572 ↩
-
J. M. Cohen, S. Kaur, Y. Li, J. Z. Kolter and A. Talwalkar (2021). "Gradient Descent on Neural Networks Typically Occurs at the Edge of Stability." ICLR 2021. arXiv:2103.00065. https://arxiv.org/abs/2103.00065 ↩
-
P. Goyal, P. Dollár, R. Girshick et al. (2017). "Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour." arXiv:1706.02677. https://arxiv.org/abs/1706.02677 ↩
-
H. Touvron et al. (2023). "Llama 2: Open Foundation and Fine-Tuned Chat Models." arXiv:2307.09288. https://arxiv.org/abs/2307.09288 ↩
