Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

AI · Training

Shape Decides the Answer.

When people say a model is “learning,” what’s literally happening is a point sliding downhill on a loss landscape — a surface whose height is the model’s error and whose location is its parameters. Gradient descent only ever does one thing: read the slope where it stands and step downhill. That means the shape of the landscape, not the algorithm, decides what answer you get. On a convex bowl there’s a single valley, so descent always rolls to the one true bottom — this is the easy, well-behaved case. On a non-convex surface with several valleys, descent rolls into whichever valley it happens to be above, so two runs starting from different points can end at different answers, and you can get trapped in a local minimum that’s worse than the best one elsewhere. And on a flat plateau the slope nearly vanishes, so each step is tiny and progress crawls to a near-halt before it reaches the bottom. The lab’s plateau is a flat-bottomed minimum (0.12x⁴), not a saddle, but the same starved gradient is what makes the “saddle points” that dominate high-dimensional loss surfaces so slow to cross. Drop a ball on each surface, change where it starts, and watch the same descent rule produce completely different fates.

gradient descent reads the slope · convex bowl always solves · non-convex can trap · plateaus starve the gradient
loss landscape

The surface of error over the model’s parameters. Training slides downhill on it toward low error.

convex

A single-valley shape: every downhill path reaches the one global minimum. The easy case.

local minimum

A valley that isn’t the lowest. Descent can settle here and get stuck, missing a better minimum elsewhere.

plateau / saddle

A near-flat region where the gradient nearly vanishes, so steps become tiny and progress stalls.

descent.js — same rule, different terrain
Ready
Pick a surface, then drop a ball and let gradient descent roll it downhill. On the convex bowl it always finds the bottom. On the double-well, where you drop it decides which minimum it reaches. On the plateau, watch the gradient — and the steps — nearly vanish.
—
position
—
loss
—
|gradient|

How it works

Gradient descent is a local procedure — it only ever knows the slope at its current point — which is the root of both its power and its limits. Because it uses local information, it scales to billions of parameters (you never need a global view of the surface), but for the same reason it is at the mercy of the landscape’s shape. On a convex surface, local downhill is globally correct: there is one minimum and every descent path reaches it, which is why classical convex problems (linear/logistic regression, SVMs) are considered “solved.” Neural-network losses are decidedly non-convex, full of many valleys — so descent finds a minimum determined by where it started and the path it took, not the minimum. For a long time people feared this meant training would get stuck in bad local minima, but a key insight from high-dimensional geometry changed the picture: in very high dimensions, points where the gradient is zero are overwhelmingly saddle points (down in some directions, up in others) rather than true local minima, and the local minima that do exist tend to have similar, near-optimal loss. The practical villain, then, isn’t a bad basin you can’t escape — it’s the flat regions and plateaus around saddles where the gradient nearly vanishes and progress grinds to a crawl. This reframes what optimizers are for: momentum, adaptive methods like Adam, good initialization, and normalization are largely about moving efficiently across flat regions and ill-conditioned valleys, not about heroically escaping deep local minima. And it’s why the starting point (initialization) genuinely matters, and why a little stochastic noise in the gradient can help — it nudges the ball off plateaus and out of shallow traps.

1

Descent reads the local slope

At its current point the ball measures the gradient (the slope) and steps downhill, proportional to the learning rate. It never sees the whole surface — only where it stands.

2

Convex bowl → always the bottom

With a single valley, every downhill path leads to the one global minimum. Drop the ball anywhere and it converges to the same, best answer. This is the easy, solvable case.

3

Two wells → the start decides

With several valleys, the ball rolls into whichever one it’s above. Drop it on the right and it can settle in a local minimum that’s worse than the deeper valley on the left — a trap that depends entirely on initialization.

✓

Plateau → the gradient vanishes

On a flat region the slope is nearly zero, so each step is tiny and progress stalls short of the bottom. The lab’s plateau is a flat-bottomed minimum, not a saddle, but a saddle starves the gradient the same way — and saddles dominate high-dimensional loss surfaces, which is what optimizers mainly fight.

Descent uses
only the local slope
Convex
one minimum, always found
Non-convex
start decides the minimum
Plateau/saddle
gradient ≈ 0 → stalls

The code

# Gradient descent: the SAME rule on any surface x = start for step in range(N): g = gradient(loss, x) # only the LOCAL slope is known x = x - lr * g # step downhill if abs(g) < tiny: # plateau / near-saddle: break # steps shrink to nothing — stalled # convex loss -> any start reaches the one global minimum # non-convex -> the start point decides WHICH minimum you get

The picture: two basins, one ridge

loss = 0.1x⁴ − 0.55x² + 0.15x + 0.6 ridge x 0.14 drop −2.2: 34 steps drop 2.2: 42 steps global: x −1.72, loss −0.41 local: x 1.59, loss 0.087 left of the ridge → global; right of it → local
The two-wells surface from the lab, drawn from its own formula. The slope is zero at three points: the two valley floors and the ridge between them at x ≈ 0.14. Every start left of the ridge rolls to the global minimum and every start right of it rolls to the local one. Descent never looks across the ridge, so the drop point alone decides the answer.

Worked example: the bowl and the plateau, step by step

Both balls dropped on the right, at the lab’s own points (x = 2.3 on the bowl, 2.2 on the plateau), following the lab’s rule: step by learning rate × slope, and stop once |gradient| falls below 0.004.

StepBowl xBowl |g|Plateau xPlateau |g|
02.3002.7602.2005.111
11.9692.3631.6892.312
51.0571.2691.1180.671
100.4860.5830.8710.317
200.1030.1230.6570.136
430.003, stops0.0030.4670.049
100——0.3150.015
248——0.203, stops0.004

On the bowl, every step multiplies x by 1 − 0.12 × 1.2 = 0.856, so the distance to the bottom halves about every 4.5 steps, all the way down. The plateau is 0.12x⁴, and its slope 0.48x³ falls with the cube of the distance: halve x and the gradient drops 8×. So the steps shrink faster than the remaining distance, and the stop rule fires at x = 0.203 after 248 steps, short of the minimum at 0. The plateau’s first step moved the ball 0.511. By step 100 a step moves it 0.0015, and the last one 0.0004. Nothing broke. The slope simply stopped carrying information.

What each terrain costs: steps to settle

Time is steps until the stop rule fires; Space is where the ball ends up.

CaseTimeSpaceWhy
Bowl, either drop43 stepsx ≈ ±0.003, loss 0.000The global minimum. Convex: any start, same answer.
Two wells, drop left (−2.2)34 stepsx −1.724, loss −0.410The global minimum, because the start is left of the ridge.
Two wells, drop right (2.2)42 stepsx 1.587, loss 0.087A local minimum, 0.497 worse. It settles just as cleanly, with no warning.
Plateau, either drop248 stepsstops at x ±0.203About 6× the bowl’s steps, and it still stops short, because the slope dies as x³.
Bowl, learning rate raisedone step at lr ≈ 0.833diverges above lr ≈ 1.667Each step multiplies x by 1 − 1.2·lr. Above 0.833 it overshoots and zig-zags; above 1.667 it blows up.

Common mistakes

  • Reading a flat loss curve as “converged”

    The plateau run stops with loss 0.0002 and a tiny gradient, 0.203 away from its minimum. A loss curve that has gone flat says the steps got small, not that you arrived.

  • One learning rate for the wall and the floor

    On the plateau the slope is 5.111 at x = 2.2 and 0.049 at x = 0.467, about 100× apart. A rate small enough for the steep wall crawls on the floor, and a rate big enough for the floor overshoots the wall. That gap is what momentum and adaptive methods close.

  • Judging a non-convex model from one run

    Both two-wells runs settled cleanly, and one is 0.497 worse. A single run cannot tell you which basin you are in. Compare several starts before you trust a result.

  • Restarting from the same point

    Plain gradient descent is deterministic: the same start lands in the same valley every time. A retry needs a new initialization, or noise in the gradient, to have any chance of crossing the ridge.

  • Treating “settled” as “good”

    The right-hand drop settled in 42 steps, only 8 more than the left. Settling fast says nothing about the quality of the minimum. Check the loss you ended at against the best you have seen.

Where this shows up in production

  • Convex models retrain identically

    Logistic regression and linear SVMs have convex losses, so retraining from any start reaches the same optimum, up to solver tolerance. That is why they are easy to audit and to reproduce.

  • Seeds in deep learning

    Neural-network losses are non-convex, so a careful comparison between two models trains each with several random seeds and compares the spread, not a single run.

  • Plateaus in training curves

    Long flat stretches followed by a sudden drop are a familiar sight in neural-network training. Warmup, learning-rate schedules and adaptive optimizers exist largely to get through them without blowing up on the steep parts.

  • The interview angle

    “Why does momentum help?” Use the plateau: the gradient there is tiny but points the same way step after step, so a running sum of it grows. Momentum keeps moving where plain descent crawls.

Quick check

1. On a convex (single-valley) loss surface, where does gradient descent end up?

2. Why can two training runs on a non-convex surface reach different answers?

3. In practice, what most slows training on high-dimensional loss surfaces?

FAQ

What is a loss landscape?

The surface you get by plotting a model’s loss (error) against its parameters: each parameter setting is a point and its height is the error there. Training moves across this surface toward lower points via gradient descent. Its shape — a smooth bowl, a rugged surface of many valleys, or flat plateaus — determines how hard training is and what solution you reach. For real networks it lives in millions of dimensions, so we only visualize simplified slices.

Do neural networks get stuck in bad local minima?

Much less than once feared. The old worry was that non-convex training would trap descent in poor minima, but high-dimensional geometry showed that zero-gradient points are overwhelmingly saddle points, not minima, and the minima that exist tend to have similar near-optimal loss. So the practical difficulty is moving through flat regions and saddles where the gradient nearly vanishes, not escaping deep bad basins. Initialization and optimizer choice still matter, and bad basins can occur in small or pathological models.

What is a saddle point and why does it slow training?

A saddle point is where the gradient is zero but it isn’t a minimum — the surface descends in some directions and rises in others, like a horse’s saddle. It slows training because the gradient is tiny in many directions nearby, so descent takes minuscule steps and creeps across the flat region before finding a clearly downhill direction. In high dimensions, saddles and their plateaus are far more common than true local minima, making them the main obstacle to fast training — which is why momentum and adaptive optimizers help.

Why does the starting point (initialization) matter in training?

Because gradient descent is local — it follows the slope from wherever it starts, so the initial parameters shape which region it explores and, on a non-convex surface, which minimum it can reach. Initialization also drives early dynamics: a poor one can land you on a vanishing-gradient plateau or where activations explode or die, stalling learning. That’s why principled schemes (Xavier/Glorot, He) set the initial scale so gradients behave, and why normalization and learning-rate warmup keep early training stable.

Keep going

Finished this one? 0 / 61 Labs done
NextGradient Descent: The Descent Next on the “Training a network” ladder · rung 4 of 7

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Labs