Gradient optimiser race
Every optimiser starts from the same idea: work out which way the loss goes down, then take a step that way. They differ in how big the step is and how much of the last step they remember. This tool runs up to three of them from the same start point so you can see those differences as paths on a contour map.
Gradient descent settles at the lowest minimum first, at step 43.
Surface and optimisers
How many times steeper y is than x. 1 is a round bowl.
Picking a surface or an optimiser sets a learning rate that works from the suggested start.
Share of the last step carried into the next.
Decay of the gradient average.
Decay of the squared-gradient average.
Or click the plot, or focus it and use the arrow keys (Shift for bigger moves).
Steps and results
| Step | 1. Gradient descent | 2. Momentum | 3. Adam |
|---|---|---|---|
| 0 | 8.82 | 8.82 | 8.82 |
| 1 | 3.7351 | 4.085 | 7.495 |
| 2 | 1.7397 | 1.2705 | 6.2835 |
| 5 | 0.3269 | 4.2682 | 3.3417 |
| 10 | 0.0498 | 1.9599 | 0.6684 |
| 20 | 0.0015 | 0.5136 | 0.3458 |
| 50 | 4.3 × 10⁻⁸ | 0.0094 | 0.0206 |
| 100 | 1.2 × 10⁻¹⁵ | 2.2 × 10⁻⁴ | 1.7 × 10⁻⁴ |
| 200 | 8.3 × 10⁻³¹ | 5.5 × 10⁻⁹ | 3.7 × 10⁻⁹ |
| Optimiser | Final loss | Converged | Where it ended |
|---|---|---|---|
| 1. Gradient descent | 8.3 × 10⁻³¹ | Step 43 | Lowest minimum |
| 2. Momentum | 5.5 × 10⁻⁹ | Step 177 | Lowest minimum |
| 3. Adam | 3.7 × 10⁻⁹ | Step 178 | Lowest minimum |
Converged means the gradient’s length stayed below 0.001 from that step to the end. The lowest loss on this surface is 0.
f = (x² + κy²) / 2. The y direction is κ times steeper, so a learning rate that is safe for y is tiny for x. Plain gradient descent diverges once the learning rate passes 2 / κ; below that it zigzags across the narrow direction.
What it shows
Optimisers differ in how big a step they take and how much of the last step they remember. This tool runs up to three from the same start point, so you can compare their paths on a contour map.
Choose from four surfaces: a stretched bowl, the Rosenbrock valley, a saddle point, and a surface with two minima. Every run uses the exact gradient, with no mini-batch noise, so only the update rule differs.
How to read it
- Grey lines are contours. Points on one line have the same loss, and lines bunch together where the surface is steep.
- Each path has its own colour and line style. A numbered circle marks where it stops. The black square is the start; × marks a minimum.
- Converged means the gradient’s length stayed below 0.001 from that step to the end. Passing through a flat spot and leaving again does not count.
- “Where it ended” says whether a converged run found the lowest minimum, a higher one, or the saddle point. Diverged means the numbers ran off to infinity.
- The chart shows each run’s loss above the lowest possible value, on a log scale. A straight falling line means the gap shrinks by the same factor each step.
Questions
Why does gradient descent diverge when the learning rate is too high?
On a quadratic like the bowl, each step multiplies the distance from the minimum along a direction by (1 − learning rate × curvature). If that factor’s size is above 1, the distance grows every step. The steepest direction sets the limit: the learning rate must stay below 2 divided by the largest curvature.
What is the difference between momentum and Nesterov momentum?
Both keep a velocity that adds a share (μ) of the previous step to the next one. Classical momentum takes the gradient where the parameters are now. Nesterov’s version takes it where the momentum is about to carry them, which lets it correct course a step earlier. Sutskever and colleagues write both in this form.
Why is Adam’s first step the same size in every direction?
Adam divides a running average of the gradient by the square root of a running average of the squared gradient. Bias correction makes both averages equal the first gradient and its square on step one, so the step is the learning rate times g / |g|: one learning rate along each axis, whatever the gradient’s size.
Where does RMSProp come from?
Geoffrey Hinton described it in lecture 6e of his Neural Networks for Machine Learning course: divide each gradient by the root of a moving average of its recent squared values. The slides credit the idea to Tijmen Tieleman and mark it as unpublished.
Why do the paths not look noisy like real training?
Real training estimates the gradient from a mini-batch, so each step is slightly off. This tool uses the exact gradient so you can compare the update rules on their own. Treat the paths as a picture of each rule, not of a full training run.
Learn it properly
Sources
- Kingma, D. P. and Ba, J. (2015). Adam: a method for stochastic optimization. ICLR 2015.
- Sutskever, I., Martens, J., Dahl, G. and Hinton, G. (2013). On the importance of initialization and momentum in deep learning. ICML 2013, PMLR 28(3).
- Hinton, G. Neural Networks for Machine Learning, lecture 6 slides (6e: rmsprop).
Explore further
- Why momentum really worksGabriel Goh’s interactive Distill article on how momentum speeds up gradient descent.
Last updated
More tools
All tools- explorerVector similarity explorerDrag vectors to see cosine, dot product and distance agree and disagree, or paste embeddings of any length.Open tool
- explorerMatrix transform visualiserSee a 2×2 matrix stretch, turn, flip or squash the plane, with its determinant and eigenvectors.Open tool
- explorerProbability distribution explorerPlot six common distributions, with mean, variance, mode and the probability of any interval.Open tool