Home / Deep Learning

Optimizers & The 3D Loss Landscape

By Updated

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!

Overview

What the terrain is made of

  • Ravines — steep in one direction, nearly flat in another. Plain SGD ricochets between the walls.
  • Plateaus — large regions where the gradient is tiny. Progress crawls because there is almost nothing to follow.
  • Saddle points — the gradient is close to zero but you are not at a minimum: the surface curves up in some directions and down in others.
0.1x

Optimization State

Global Minimum is at (0, 0) Watch out for Local Minima!

Optimizers in 3D: A Practical Guide

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.

Saddles matter more than local minima

The folk explanation of training failure is "it got stuck in a local minimum". In high dimensions that is mostly wrong. For a point to be a local minimum, the surface must curve upward in every direction at once — and with millions of parameters that is vanishingly unlikely. Saddle points, where it curves up in some directions and down in others, are enormously more common.

This is a practical difference. A local minimum 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.

The loss surface as a landscape

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, because the features that make optimisation hard are visible in three dimensions:

  • Ravines — steep in one direction, nearly flat in another. Plain gradient descent zigzags across the steep direction and crawls along the flat one.
  • Saddle points — downhill in some directions, uphill in others, with a gradient of zero at the centre. In high dimensions these vastly outnumber local minima, because it is improbable for millions of curvature signs to agree.
  • Plateaus — large flat regions where gradients are tiny and progress stalls.
  • Sharp versus flat minima — both fit the training data; flat ones tend to generalise better, because a small shift in the weights (or in the data) changes the loss less.

How each optimiser behaves on that landscape

Plain SGD takes a step directly downhill, scaled by the learning rate. In a ravine that means oscillating across the narrow direction while barely advancing along the valley floor.

Momentum accumulates velocity, so the oscillations partly cancel and the consistent downhill direction builds speed. It is the difference between a ball on a rough surface and one with mass.

Adam gives every weight its own effective step size, dividing by the square root of its recent squared gradients. Weights on flat directions get larger steps and weights on steep ones get smaller, which reshapes the ravine into something closer to a bowl.

OptimiserIn a ravineOn a plateauNear a saddle
SGDZigzags slowlyStallsCan stall
SGD + momentumAdvances along the valleyCoasts throughCoasts through
AdamAdvances directlyAmplifies small gradientsEscapes readily

That plateau row explains a real advantage of adaptive methods: dividing by a small accumulated gradient magnitude increases the step, so Adam keeps moving where SGD would sit still.

Saddle points, not local minima

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 minimum, the curvature must be positive in every direction. With ten million parameters, that requires ten million signs to agree, which is vanishingly unlikely. Almost every point where the gradient vanishes is a saddle — downhill in at least one direction.

That is good news, because saddles are escapable. The stochastic noise from mini-batches is usually enough to push the model off the ridge and onto a descending path, which is one reason mini-batch training generalises better than full-batch.

It also reframes what training is doing: not searching for a unique global minimum, but descending through a landscape of many near-equivalent good solutions, most of which are fine.

Try this above

  1. Run SGD (Red) alone and watch it stall when it reaches a flat region — near-zero gradient means near-zero step.
  2. Switch to Momentum (Blue) from the same start. It coasts across the flat section on accumulated velocity.
  3. Select All (Compare) and note the arrival order, then change Learning Rate and see whether the order holds. It often does not.
  4. Slow Sim Speed right down at the moment each optimiser crosses the ridge — that is where the differences are widest.

What usually goes wrong

Over-reading the picture. This surface has two parameters. 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.

In one line

The shape of the surface, not the cleverness of the algorithm, decides which optimiser looks good.

Sharp and flat minima

Two solutions can fit the training data equally well and behave very differently on new data.

A sharp minimum 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 minimum is a broad basin: nearby weights are almost as good, so a small mismatch between train and test costs little.

Several observed behaviours follow from this:

  • Small batches generalise slightly better because their gradient noise makes it hard to settle into a narrow crevice.
  • Very large batches sometimes generalise worse, and techniques like LARS and longer warm-up exist to counter it.
  • Weight averaging (SWA) averages weights from several late-training points, landing nearer the centre of a basin than any individual point.
  • Sharpness-aware minimisation (SAM) explicitly penalises sharpness by taking a step towards the worst nearby point before updating.

Visualising a real loss surface

You can plot the landscape of an actual network, and the pictures are informative.

Take a trained model's weights, pick two random directions in weight space, and evaluate 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.

Four surfaces that break four different optimisers

A bowl, a ravine, a saddle and a plateau. Each one defeats a different optimiser, and running all four on all four shows why there is no single right answer.

example_01.pyNumPy
Output

Questions people ask

Does the optimiser find the global minimum? No, and it does not need to. High-dimensional landscapes have vast numbers of near-equivalent good solutions.

Why does momentum help? It averages recent gradients, so consistent directions accumulate and oscillations cancel — exactly 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 difference between the learning rate and momentum? The learning rate is how far to step; momentum is how much of the previous direction to keep.

Can I see whether my minimum is flat? Approximately — perturb the weights slightly and measure how much the loss rises. Large increases mean a sharp minimum.

Recap in one screen

  • Loss landscapes have ravines, plateaus and saddles; the optimiser's job is to navigate them.
  • Momentum damps oscillation across a ravine; adaptive methods rescale each direction.
  • In high dimensions almost every zero-gradient point is a saddle, not a local minimum — and noise escapes them.
  • Flat minima generalise better than sharp ones, which is why small batches and weight averaging help.
  • Skip connections visibly smooth the surface, which is a direct explanation of why they work.

Recall check

0 of 4

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. What is meant by “Small batches generalise slightly better” here?

  2. What is meant by “Very large batches sometimes generalise worse” here?

  3. What is meant by “Weight averaging” here?

  4. What is meant by “Sharpness-aware minimisation” here?

Cheat sheet

Optimizers in 3D

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!

DEEP LEARNING · vizlearn.in/deep_learning/optimizers_in_3d.html

Further reading

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.