Optimisation: gradient descent, momentum and Adam
ML · Chapter 611 min readAsked at Two Sigma, Citadel, QuantCo, Jump
Assumes Unsupervised learning: clustering assets and correlation structure.
After this lesson you should be able to
- Say why stochastic gradients are used rather than full-batch ones.
- Explain what momentum and adaptive rates each fix.
- Describe how convexity changes what convergence means.
Fitting a model means minimising a loss, and for anything beyond a closed form that means gradient descent. The variants all address the same two problems: the gradient is expensive to compute exactly, and the loss surface is badly scaled in different directions.
Equation 6.1
Stochastic gradient descent
Step downhill using the gradient computed on a small batch rather than on the whole dataset.
- Learning rate — the single most important hyperparameter.
- A mini-batch. Its size trades gradient noise against computational efficiency.
Why the noisy gradient is better. The obvious objection is that a batch gradient is an approximation, so it must be worse. It is worse per step and far better per unit of computation: you can take a hundred noisy steps for the cost of one exact one, and a hundred noisy steps make much more progress. The noise also helps — it lets the iterate escape shallow local minima and saddle points, which full-batch descent would sit in forever. Approximation is the feature, not a compromise.
| Method | Problem it addresses | Mechanism |
|---|---|---|
| Momentum | Oscillation across a narrow valley | Accumulate an exponentially weighted velocity |
| Nesterov | Momentum overshooting | Evaluate the gradient at the look-ahead point |
| AdaGrad | Parameters needing different step sizes | Divide by the accumulated squared gradient |
| RMSProp | AdaGrad’s step size decaying to zero | Use an exponentially weighted average instead |
| Adam | Both at once | Momentum plus RMSProp, with bias correction |
Proposition 6.3
What convexity buys
On a convex loss, any local minimum is global and gradient descent converges to it from any starting point — the problem is solved, and only the speed is in question. Ridge, lasso, logistic regression and SVMs are all convex. Neural networks are not, so the solution depends on initialisation and on the path taken, and "converged" means only that it stopped moving.
Holds when
- Convexity is why classical statistical models have reproducible answers and deep models do not.
- On a non-convex loss, different random seeds give genuinely different models — which is an argument for ensembling them.
The rest of this lesson is in Premium
You have read the opening. 10 more sections follow, including 4 worked examples and 3 quick checks.
Nothing is charged for 7 days, and you can cancel before then. Or read The law of large numbers and the central limit theorem in full, free.