fθ(x) — decision boundary
click the landscape
computing the landscape…

What gradient descent actually sees

An explorable, exactly-computed high-dimensional loss landscape.

Every pixel of the landscape on this page is a real forward pass of a real network at a real point in its 1,251-dimensional weight space, computed live on your GPU. Drag to move. Scroll to zoom. Click anywhere to see the function that point of weight space computes. Nothing is a cartoon.

↓ scroll
Chapter 0

The setup

The network is tiny on purpose: 2 → 32 → 32 → 3, tanh, 1,251 weights, trained by plain full-batch gradient descent (no momentum, no noise, no tricks) to classify a three-armed spiral with mean-squared error. Tiny enough that we can compute the exact Hessian — all 1,251 curvatures and directions — at every stage of training, and cheap enough that your GPU can evaluate the loss at hundreds of thousands of points of weight space per second. Rich enough that the things modern deep nets do in their landscapes — progressive sharpening and the edge of stability, saddle plateaus, a gradient confined to a tiny subspace, connected minima, a manifold of solutions — all show up here, and can be inspected exactly rather than estimated.

The landscape is 1,251-dimensional. You can only ever look at a two-dimensional slice of it. The whole point of this page is that which slice you look at changes everything.

the toy problem, in numbers
Chapter 1

A random slice lies to you

This is the loss around the network at step «7,500» of training, on a random 2-D plane through that point. It looks like the picture in every textbook: a smooth, gentle bowl, the network sitting near its bottom. Across the whole view the loss only varies between «0.10» and «0.24».

Same point. Same landscape. Different plane: the horizontal axis is now the eigenvector of the Hessian with the largest eigenvalue; the vertical axis is the same random direction as before. What was a bowl is a canyon. Along the sharp axis the loss rises to «15» over the same distance that took it to 0.24 before — «157»× the curvature of a typical direction.

The reason is not that the random slice was unlucky. It's that in 1,251 dimensions every random direction is nearly orthogonal to the handful of sharp ones. The curvature along a random unit direction u is uᵀHu, whose average over u is tr(H)/P = «0.102». The largest eigenvalue is «16.2». The histogram on the right shows 500 random directions: the best of them reaches «2.4%» of the top eigenvalue. A random slice is an average over all directions, and the average is flat.

Look at the full spectrum (the second chart). Of 1,251 eigenvalues, only «16» exceed a tenth of the largest; the median is «3 × 10⁻⁵». A dense bulk hugging zero and a few outliers. This is the shape found in every neural network anyone has looked at, from this toy to ImageNet models (Sagun et al. 2017, Papyan 2019): a landscape that is, to first order, a few-dimensional canyon carved into a thousand-dimensional plain that is almost perfectly flat.

Small aside: the two sharpest directions at this moment have eigenvalues 16.17 and 16.03 — nearly tied — so the plane of the top two eigenvectors is a round, narrow bowl rather than a canyon. Try it in the explore panel.

Everything below is about what gradient descent does with that canyon.

Chapter 2

Gradient descent sharpens the landscape until it can’t

Watch the largest Hessian eigenvalue — the curvature across the canyon, call it the sharpness — as training proceeds. It is not constant. Early on it rises steadily, from «4.6» at initialisation: gradient descent is walking into ever-narrower parts of the valley. This is progressive sharpening, and it happens with no regularisation pushing either way.

Then it stops rising, at 2/η = «16», and stays there for the rest of training. It gets there at step «3,188» — a tenth of the way in — and for the remaining «27,000» steps it never leaves the band 0.97–1.05 of that value.

That number is not a coincidence. Gradient descent with step size η is stable on a quadratic only if the curvature is below 2/η; above that, each step overshoots the valley floor and lands further up the other wall than it started. So the moment the sharpness crosses 2/η, GD starts to diverge along the sharpest direction — and the divergence itself pushes the iterate into a region where the sharpness is slightly lower, and it’s caught. It hovers there, on the edge, for tens of thousands of steps. Cohen et al. 2021 named this the Edge of Stability.

The landscape on the right is centred on the current iterate, in the plane of the two sharpest directions, and the bright thread is the actual sequence of GD steps ±30 around it. GD is not sliding down the canyon. It is bouncing from wall to wall — left, right, left, right, period two — across the sharp direction, while drifting down the canyon floor in the other. After the edge is reached the loss goes up on «23.5%» of all steps. Scrub the timeline.

Learning-rate sweep: sharpness curves for η ∈ {0.0625, 0.125, 0.25, 0.5}, each with its own 2/η line.

Change the learning rate and the sharpness settles at a different height — «31.9, 16.0, 8.0, 4.0» for 2/η = 32, 16, 8, 4. Gradient descent does not find a flat minimum. The step size decides how sharp a region GD is allowed to occupy, and GD goes exactly as sharp as it is allowed. Whatever regularising effect a large learning rate has, this is where it comes from — not from noise (there is none here; this is deterministic full-batch GD), but from the discrete step itself.

Chapter 3

Gradient descent happens in a tiny subspace

If the landscape is a few-dimensional canyon in a flat plain, where does the gradient point?

The chart shows the fraction of the squared gradient norm that lies in the span of the top-3 and top-10 Hessian eigenvectors, over training. At initialisation it is «0.44» for the top 3. By step «3,562» — the same moment the sharpness hits 2/η — it is above 0.99, and it stays there: the median over the rest of training is «1.000». The gradient points almost entirely across the canyon, into three directions, and almost not at all along the other 1,248. (Gur-Ari, Roberts, Dyer 2018.)

Which means the 1,251-dimensional trajectory is really a low-dimensional curve. A principal- component analysis of the path taken by the weights puts «89.7%» of its variance in one direction and «96.3%» in two. The landscape on the right is that plane, with the whole trajectory drawn on it: initialisation at one end, the solution at the other.

Notice how little of that plane the path uses, and notice the scale: the network ends «13.5» units from where it started, on a weight vector of length «18.7».

Chapter 4

The plateau is a saddle

Now train the same network from a much smaller initialisation — every weight scaled by «0.01». The loss curve is no longer a smooth decay. It drops in the first «200» steps to exactly «⅓», and then sits there for «25,000» steps — «42%» of the whole run — before anything else happens.

⅓ is not an arbitrary number. It is the loss of the network that ignores its input and answers (⅓, ⅓, ⅓) for everything: the constant predictor. With tiny weights, that is what the network computes, and the constant predictor is a saddle point of the loss. At the middle of the plateau the gradient norm is «7 × 10⁻⁴» (it bottoms out at «4 × 10⁻⁵»); gradient descent has essentially stopped. And the Hessian there has what a saddle has: negative eigenvalues — «238» of them — but the most negative is only «−0.008». Two hundred directions lead downhill, all of them almost flat.

The landscape on the right is the plane spanned by the most negative eigenvector and the gradient. You are looking at a saddle. GD leaves it along the negative direction at a rate that grows like eη|λ|t, which with |λ| = 0.008 takes thousands of steps to become visible: the escape is exponentially slow in a direction that is barely curved. The plateau you have stared at in a training curve is the time it takes to leave a ridge like this one.

Then look at what the function does (the inset: the network’s classification of the input plane, rendered live from the current weights). On the plateau the network is a constant. At the escape it becomes a linear-ish classifier, and only then does the boundary begin to curl around the spiral arms. Scrub the timeline through the drop and watch the boundary grow.

Honesty note: in deeper or narrower networks this happens repeatedly — a staircase of saddles, one feature learned per escape (Jacot et al. 2021, Saxe et al. 2013). On this problem we found one dominant plateau, the constant-predictor saddle, in 24 configurations tried; after it the descent is continuous.

Chapter 5

There is no basin. There is a manifold of solutions.

Here is the network after 30,000 steps of gradient descent: train accuracy «100%», loss «0.0064». Not zero. Push it the rest of the way to the zero-loss set — «500» Gauss-Newton steps, no gradient descent could get there in any reasonable time, more on that below — and the loss is «7 × 10⁻¹⁰». Everyone draws this point as the bottom of a bowl.

Count the eigenvalues of its Hessian that are smaller than 10⁻¹⁰ — zero, for a matrix whose largest eigenvalue is «80»: «625».

At least 351 of them are forced. At a point of zero loss the Hessian of a mean-squared error equals JᵀJ/N, where J is the 900 × 1,251 Jacobian of the network’s outputs with respect to its weights. Its rank is at most 900, so at least 1,251 − 900 = 351 eigenvalues are exactly zero. Those directions are the tangent space of a surface: the set of all weight vectors that fit the data perfectly is a manifold of dimension at least 351, and the “minimum” is a point on it. Move along the manifold and the loss does not change at all. This particular solution is flatter still — «274» more directions with curvature below 10⁻¹⁰, most of them inside the middle weight matrix. The bowl is a trough with hundreds of flat directions.

So are two solutions from different random initialisations different minima? Here are two, A and B. Interpolate linearly between them and the loss climbs to «3.2» in the middle — «10»× the loss at initialisation. A barrier. Separate basins, apparently.

But a network with 32 hidden units in a layer is the same function under any of the 32! orderings of those units. B is A’s twin under a permutation nobody chose. Find the permutation that best aligns B’s neurons with A’s (Ainsworth et al. 2022) and the two solutions are suddenly «16» units apart instead of «26.5», and the barrier drops to «1.0». Then let a single control point bend the path (Garipov et al. 2018): the highest loss anywhere along the curve is «0.010», «1.35»× the loss at the endpoints. There is a path from A to B along which the network is a near-perfect classifier the whole way.

The landscape on the right is the plane containing A, the aligned B, and the control point. You are looking at two apparent basins and the curved tunnel of the solution manifold that joins them. Pan around it.

Why GD never reached the manifold: after the sharp directions are fitted, the remaining error lives in directions whose curvature is «~10⁻⁶». Gradient descent moves along a direction of curvature λ by a factor (1 − ηλ) per step, so those directions need ~1/(ηλ) ≈ 10⁷ steps per e-fold. The loss decays as a power law, not an exponential. The long, flat tail of every training curve you have ever seen is the long, flat tail of this spectrum.

Chapter 6

The straight line from init to solution is downhill all the way

One last slice. Draw the straight line from the random initialisation to the final solution and evaluate the loss along it. It decreases monotonically — strictly, at every one of «201» samples. There was never a hill in the way. (Goodfellow, Vinyals, Saxe 2014.)

Gradient descent did not take that line. The path it took is «59»× longer than the chord («800» units of travel to cover «13.5» units of distance) — almost all of it the wall-to-wall bouncing from Chapter 2 — and it curls inside the few directions of Chapter 3. The landscape on the right is the plane spanned by the chord and the dominant direction of the trajectory perpendicular to it: the straight line, and the actual path, side by side.

Chapter 7

Noise walks along the manifold to flatter ground

Same learning rate, same data, same final accuracy, but now stochastic: minibatches of 32 instead of the full 300. The sharpness never reaches 2/η = 16. It settles at «12.9», about «80%» of the edge. On the solution manifold the loss is zero in every direction, so gradient descent has no reason to prefer one point of it over another; noise does. Every noisy step kicks the iterate off the manifold and the gradient brings it back, and the net effect of kick-and-return is a drift along the manifold toward where the curvature is smaller (Blanc et al. 2020, Li et al. 2021). Flat minima are not found. They are drifted into.

Coda

What to take away

  • The landscape has a few sharp directions and a thousand flat ones. Anything you learned from a 2-D picture that wasn’t aligned with the sharp ones was an average, and averages are bowls.
  • Gradient descent is not a ball rolling downhill. It is a process that sharpens the valley it is in until the step size forbids it, then rides the edge, bouncing, with its gradient confined to three directions out of 1,251.
  • Plateaus are saddles with hundreds of downhill directions, all nearly flat.
  • “Minima” are a manifold. Basins are permutations of each other. Flatness is selected by the step size or drifted into by noise, not found.
  • The end of training is slow because the spectrum has no bottom: below the outliers, the curvatures decay all the way to zero.
  • Every one of these statements is a computed fact about the landscape on this page, not a metaphor. Go drag it around.

Built with a 2→32→32→3 tanh MLP, MSE, full-batch GD (η = 0.125), 30,000 steps. All Hessians exact (float64), all landscape pixels exact (GPU, float32). The manifold point was reached with Levenberg–Marquardt from the GD endpoint. {{repo_link_sentence}} Made with Claude Code.

—step —loss —λmax
— —
drag the surface · shift+wheel to zoom · ← → step · space play