Machine Learning Engineeringsimulator

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.

Step 200 of 200
Lowest minimum reached

Gradient descent settles at the lowest minimum first, at step 43.

Steps to settle43Gradient descent
123
1. Gradient descent2. Momentum3. AdamStartMinimum
10⁻⁸10⁻⁷10⁻⁶10⁻⁵10⁻⁴10⁻³10⁻²10⁻¹1050100150200StepLoss above the minimum
1. Gradient descent2. Momentum3. Adam

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

Loss at selected steps; the highlighted row is the step shown on the plot
Step1. Gradient descent2. Momentum3. Adam
08.828.828.82
13.73514.0857.495
21.73971.27056.2835
50.32694.26823.3417
100.04981.95990.6684
200.00150.51360.3458
504.3 × 10⁻⁸0.00940.0206
1001.2 × 10⁻¹⁵2.2 × 10⁻⁴1.7 × 10⁻⁴
2008.3 × 10⁻³¹5.5 × 10⁻⁹3.7 × 10⁻⁹
Results after 200 steps
OptimiserFinal lossConvergedWhere it ended
1. Gradient descent8.3 × 10⁻³¹Step 43Lowest minimum
2. Momentum5.5 × 10⁻⁹Step 177Lowest minimum
3. Adam3.7 × 10⁻⁹Step 178Lowest 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.

Stretched bowl

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

Explore further

Last updated

More tools

All tools

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.