Visualize how different optimization algorithms navigate complex terrain, escape local minima, and find the global minimum. Run multiple in parallel to observe realistic relative speeds!
At a saddle point, plain SGD stalls since the gradient is near zero in each way — momentum. Or a per-param scaling like Adam, is what pushes through. A ravine (a long narrow valley) is the other classic failure mode: the gradient points across the valley rather than along it. So plain SGD oscillates side to side instead of progressing toward the min. Momentum damps the oscillation by averaging past gradients. And RMSprop scales each param's learning rate by the recent magnitude of its gradient. It shrinks the step across the valley and lets the step along it dominate. Adam mixes both: it carries a momentum term and a per-param scaling term, with bias correction for the first few steps. The 3D loss surface makes these gaps visible in a way that 2D curves cannot — you can see the trajectory spiralling into a bowl, overshooting a ridge, or threading through a saddle. This page plots three loss surfaces (a bowl, a ravine, and a saddle), runs SGD, momentum, RMSprop, and Adam on each, and shows the trajectory and convergence speed side by side.
Visualize how different optimization algorithms navigate complex terrain, escape local minima, and find the global minimum.
A loss surface in three dimensions is the only version you can actually look at. The features that decide which optimiser wins — ravines, plateaus, saddle points — are all visible here.
At a saddle point, plain SGD stalls since the gradient is near zero in each way — momentum. Or a per-param scaling like Adam, is what pushes through. A ravine (a long narrow valley) is the other classic failure mode: the gradient points across the valley rather than along it. So plain SGD oscillates side to side instead of progressing toward the min. Momentum damps the oscillation by averaging past gradients. And RMSprop scales each param's learning rate by the recent magnitude of its gradient. It shrinks the step across the valley and lets the step along it dominate. Adam mixes both: it carries a momentum term and a per-param scaling term, with bias correction for the first few steps. The 3D loss surface makes these gaps visible in a way that 2D curves cannot — you can see the trajectory spiralling into a bowl, overshooting a ridge, or threading through a saddle. This page plots three loss surfaces (a bowl, a ravine, and a saddle), runs SGD, momentum, RMSprop, and Adam on each, and shows the trajectory and convergence speed side by side.
The folk explanation of training failure is "it got stuck in a local min". In high dimensions that is mostly wrong. For a point to be a local min, the surface must curve upward in each way at once — and with millions of params that is vanishingly unlikely. Saddle points, where it curves up in some ways and down in others, are enormously more common.
This is a real gap. A local min is a trap. A saddle is not — there is a way down. And an optimiser with momentum carries enough velocity from earlier steps to keep moving across the flat region until it finds one.
Picture two weights on the horizontal axes and the loss on the vertical one. Training is a ball rolling downhill on that surface. And the optimiser decides how the ball moves.
Real networks have millions of weights. So the surface is millions of dimensions rather than two. The picture is still useful, since the features that make optimisation hard are visible in three dimensions:
Plain SGD takes a step right downhill, scaled by the learning rate. In a ravine that means oscillating across the narrow way while barely advancing along the valley floor.
Momentum accumulates velocity, so the oscillations partly cancel and the consistent downhill way builds speed. It is the gap between a ball on a rough surface and one with mass.
Adam gives each weight its own effective step size, dividing by the square root of its recent squared gradients. Weights on flat ways get more steps and weights on steep ones get less. It reshapes the ravine into something closer to a bowl.
| Optimiser | In a ravine | On a plateau | Near a saddle |
|---|---|---|---|
| SGD | Zigzags slowly | Stalls | Can stall |
| SGD + momentum | Advances along the valley | Coasts through | Coasts through |
| Adam | Advances directly | Amplifies small gradients | Escapes readily |
That plateau row explains a real advantage of adaptive ways: dividing by a small accumulated gradient magnitude raises the step. So Adam keeps moving where SGD would sit still.
The old fear was that gradient descent would get stuck in bad local minima. High-dimensional geometry says otherwise.
For a stationary point to be a local min, the curvature must be positive in each way. With ten million params, that needs ten million signs to agree. It is vanishingly unlikely. Almost each point where the gradient vanishes is a saddle — downhill in at least one way.
That is good news, since saddles are escapable. The stochastic noise from mini-batches is often enough to push the net off the ridge and onto a descending path. It is one reason mini-batch training generalises better than full-batch.
It also reframes what training is doing: not searching for a unique global min. But descending through a field of many near-equivalent good solutions, most of which are fine.
Over-reading the picture. This surface has two params. A real network has millions. And its loss landscape has properties that genuinely do not exist in 3D. Use this to build intuition about momentum and adaptive step sizes. Do not use it to conclude anything about how many minima a real network has.Judging an optimiser from one starting point. Change where the run begins and the ranking often changes with it. A single trajectory is an anecdote.
The shape of the surface, not the cleverness of the algorithm, decides which optimiser looks good.
Two solutions can fit the training data equally well and behave very differently on new data.
A sharp min is a narrow crevice: move the weights slightly and the loss rises steeply. Since the test distribution differs slightly from the training one, that sensitivity translates into worse test performance.
A flat min is a broad basin: nearby weights are almost as good. So a small mismatch between train and test costs little.
A few observed behaviours follow from this:
You can plot the field of an actual network. And the pictures are informative.
Take a trained net's weights, pick two random ways in weight space. And test the loss on a grid of small perturbations along them. Plotting that grid gives a two-dimensional slice through a million-dimensional surface.
What such plots reliably show: networks without skip connections have chaotic, spiky surfaces. Networks with them are dramatically smoother. That is a fairly direct visual explanation of why residual connections make deep networks trainable. And it is one of the more satisfying results in the area.
The caveat is that a two-dimensional slice of a million-dimensional surface can be misleading. Treat these plots as intuition, not proof.
A bowl, a ravine, a saddle and a plateau. Each one defeats a other optimiser. And running all four on all four shows why there is no single right answer.
Now read the table surface by surface to see what each one reveals about optimiser design.
The saddle and plateau are the surfaces that split adaptive ways from plain SGD.
Does the optimiser find the global min? No. And it does not need to. High-dimensional landscapes have vast counts of near-equivalent good solutions.
Why does momentum help? It averages recent gradients. So consistent ways accumulate and oscillations cancel — just what a ravine needs.
Are local minima a problem? Rarely. Saddle points and plateaus are the real obstacles in high dimensions.
Should I use a large batch to get a cleaner gradient? A cleaner gradient is not automatically better — the noise helps escape saddles and avoid sharp minima. Scale the learning rate if you do increase the batch.
What is the gap between the learning rate and momentum? The learning rate is how far to step. Momentum is how much of the last way to keep.
Can I see whether my min is flat? About — perturb the weights slightly and measure how much the loss rises. Large raises mean a sharp min.
Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.
What is meant by “Small batches generalise slightly better” here?
What is meant by “Very large batches sometimes generalise worse” here?
What is meant by “Weight averaging” here?
What is meant by “Sharpness-aware minimisation” here?
Race SGD, Momentum, RMSprop and Adam across a 3D loss landscape and watch which of them escape local minima and which get stuck.