Skip to content

2103: Loss Landscape Geometry - Curvature, Saddles, and the Shape of Optimization

⏱ 11 min read·📅 Last updated: 2026-10-17

Difficulty: ⭐⭐ Intermediate

Estimated Time: 4 hours

Table of Contents


Learning Objectives

After completing this lesson, you will be able to:

  • Read a Hessian as a geometry: classify a critical point as minimum, maximum, or saddle from the signs of its curvatures, and state the gradient-descent step factor 1 - eta * lambda along each axis
  • Price anisotropy with the condition number (kappa = 4.0 for the lesson's bowl) and explain why the flat direction, not the steep one, is what slows gradient descent down
  • Separate the two saddles: the sign-flip saddle that gradient descent escapes on its own (|y| crosses 1.0 at step 25) from the flat-direction stall that traps it (1,151 steps for x to fall to a tenth of its start)
  • Show that Newton's method is not a minimizer - it lands on the symmetric saddle (0.00, 0.00) in one step - and connect that failure to the saddle-free Newton fix
  • Run the counting argument that makes high dimensions saddle country: with P(upward) = 0.5 per direction, local minima fall from 2,439 of 10,000 critical points at n = 2 to 0 of 10,000 at n = 100 while mean negative directions climb from 1.0 to 50.0
  • Apply the second-derivative convexity test on a grid (769 of 4,001 points with f'' < 0) and state what convexity uniquely guarantees: every local minimum is the global one
  • Read momentum as inertia on the landscape: over 1,000 random starts on the asymmetric double well, it carries 28 of plain gradient descent's 495 shallow-basin starts across the barrier into the deep well

Abstract

This module's quiz asks what a saddle point is, where gradient descent gets stuck, and what convexity guarantees - and until this lesson the review map's only pointer was 2102, which computes the Hessian with create_graph=True but never reads the landscape that matrix describes. The vocabulary proves the gap: 'saddle' appears nowhere in the corpus outside this module's quiz, and 'loss landscape' appears only as a practice-exercise plot title. This lesson is the reading half of second-order calculus. Where 2102 builds the machinery - the chain rule, autograd, the Hessian computation - this lesson uses it to answer the questions every practitioner actually has about their loss curve: why does training slow to a crawl on some surfaces and plunge on others, why does the folklore blame "bad local minima" when the mathematics points at saddles, and when is momentum doing real work versus adding noise. The boundary is owned honestly: 2101 owns the linear-algebra objects, 2102 owns the Hessian compute and the backprop engine that estimates the gradient, 2201 owns the autograd engineering, 5501 owns the optimizer update rules this lesson's campaign drives, 5406 owns the stability wall eta_max = 2/lambda_max whose lambda_max is exactly this lesson's maximum curvature, 4401 owns GPTQ's use of the same Hessian for quantization error compensation - same matrix, different job - and 2103 owns the geometry itself: the classification of critical points, the flat-direction trap, the high-dimensional argument, the convexity test, and inertia as a landscape-reading device.


Reading the Second Derivative as Geometry

The first derivative is a slope; the second derivative is a shape. For a one-dimensional function, f''(x) is the curvature at x: positive means the function bends upward (a valley), negative means it bends downward (a hill). Multivariate functions generalize this to one curvature per direction, and the Hessian collects them: entry (i, j) is the mixed second derivative, and along the Hessian's eigenvector directions the eigenvalues are pure curvatures.

The axis-aligned quadratic toys keep that statement exact without any eigendecomposition. For f(x, y) = 0.5*L1*x^2 + 0.5*L2*y^2, the Hessian is diag(L1, L2), the diagonal entries are the curvatures along x and y, and their signs classify the critical point at the origin - both positive a minimum, both negative a maximum, mixed a saddle, and a zero leaving one direction with no opinion at all. The same numbers price gradient descent: along each axis one step multiplies the error by 1 - eta * lambda, so the table below is simultaneously a classification and a convergence prediction.

# Loss-Landscape Geometry: the Hessian's diagonal entries ARE the curvatures.
# Axis-aligned quadratic toys f(x, y) = 0.5*L1*x^2 + 0.5*L2*y^2 keep the
# algebra exact: the Hessian is diag(L1, L2) and each diagonal entry is the
# curvature along its axis; their signs classify the critical point.
TOYS = [
    ("bowl (min)", 1.0, 4.0),
    ("dome (max)", -1.0, -4.0),
    ("saddle", 1.0, -4.0),
    ("half-pipe", 0.0, 4.0),
]
ETA = 0.10
print("landscape      L1    L2   class           GD factor x  GD factor y")
for name, l1, l2 in TOYS:
    if l1 > 0 and l2 > 0:
        cls = "local minimum"
    elif l1 < 0 and l2 < 0:
        cls = "local maximum"
    elif l1 == 0 or l2 == 0:
        cls = "flat direction"
    else:
        cls = "saddle point"
    fx = 1 - ETA * l1
    fy = 1 - ETA * l2
    print(f"{name:<14}{l1:5.1f}{l2:6.1f}   {cls:<15}{fx:11.2f}{fy:13.2f}")
kappa = 4.0 / 1.0
print(f"\nbowl condition number kappa = L_max / L_min = {kappa:.1f}: GD crawls")
print("along L_min and leaps along L_max - the flat direction is the slow one.")

Read the bowl's two factors against each other: 0.90 along x against 0.60 along y. The steep axis (curvature 4.0) shrinks its error 40 percent every step (factor 0.60); the gentle axis (curvature 1.0) only 10 percent (factor 0.90). Their ratio is the condition number kappa = 4.0, and it is the geometry behind every "your learning rate is fighting your landscape" debugging session: the step size that keeps the steep direction stable (eta < 2/4.0 = 0.5) is the same step size that makes the flat direction crawl. This is also, verbatim, the lambda that 5406's stability wall names: eta_max = 2/lambda_max is a curvature statement.


The Saddle and the Flat-Direction Trap

A saddle mixes an attractive direction with a repelling one, and the folklore treats it as a trap. The walk below separates the two failure modes hiding inside that word. The landscape is f(x, y) = 0.5*0.02*x^2 - 0.5*1.0*y^2: a valley tilted upward in y (the repelling direction, curvature -1.0) and nearly flat in x (the trapping direction, curvature +0.02). Gradient descent starts at (0.10, 0.10).

# The stall is not the saddle's sign flip - it is the small |curvature|.
# f(x, y) = 0.5*0.02*x^2 - 0.5*1.0*y^2: a valley tilted up in y (the
# repelling direction) and nearly flat in x (the trapping direction).
LX, LY, ETA = 0.02, 1.0, 0.1
x, y = 0.1, 0.1
t_escape = None
for t in range(1, 200):
    x -= ETA * (LX * x)
    y -= ETA * (-LY * y)
    if abs(y) > 1.0:
        t_escape = t
        break
print(f"GD from (0.10, 0.10), eta = {ETA}, on diag(0.02, -1.0):")
print(f"  y crosses |y| = 1.0 at step {t_escape} (x-factor per step {1 - ETA * LX:.3f})")
print(f"  x at that step: {x:.4f} of the starting 0.1000 - the flat axis barely moved")
steps_x = 0
x2 = 0.1
while abs(x2) > 0.01:
    x2 -= ETA * (LX * x2)
    steps_x += 1
print(f"  x reaching 0.01 needs {steps_x} steps: escape time ~ 1/(eta*|L_min|)")
# Newton's method walks straight to ANY stationary point - saddles included.
# grad = (x, -y); Newton: theta - grad / H_ii per axis.
xn, yn = 0.1, 0.1
xn -= xn / 1.0
yn -= (-yn) / (-1.0)
print(f"Newton on the symmetric saddle diag(1, -1) from (0.10, 0.10): "
      f"one step to ({xn:.2f}, {yn:.2f})")
print("Newton is not a minimizer: it converges to every stationary point, "
      "saddles first.")

The repelling direction is no obstacle at all: y crosses 1.0 at step 25, amplified by 1.10 per step the moment it leaves zero. The attractive direction is the trap - not because of its sign, but because of its size. While y makes its escape, x has moved from 0.1000 to 0.0951; at the 0.998 per-step factor the flat axis needs 1,151 steps just to fall to a tenth of its starting distance. Escape time scales like 1/(eta * |lambda_min|), so a direction with curvature near zero is a direction where gradient descent measures time in geological units. That is the honest content of "gradient descent can get stuck in local minima or saddle points": the stall lives on flat curvature, and a saddle is where flat curvature concentrates.

Newton's method is the mirror-image warning. On the symmetric saddle diag(1, -1) it takes one step from (0.10, 0.10) and lands on (0.00, 0.00) - the saddle itself, found perfectly. Newton divides the gradient by the curvature, so it converges to every stationary point: minima, maxima, and saddles alike, with no preference among them. This is exactly the failure Dauphin et al. correct with the saddle-free Newton method (arXiv 1405.4604; the current arXiv title reads "On the saddle point problem for non-convex optimization", live-verified on the day): flip the Hessian's negative eigenvalues to positive before stepping, and the second-order update becomes descent that still leaps across flat directions but can no longer aim at saddles.


Why High Dimensions Are Saddle Country

The counting argument behind "saddles, not local minima" fits in four lines. A critical point is a local minimum only if every single direction curves upward. Model each direction as an independent coin flip - upward with probability P(up) = 0.5 - and count what comes out.

# Dauphin et al.'s argument, made countable: a critical point is a local
# minimum only if EVERY direction curves upward. Model each direction as
# an independent coin flip with P(upward) = P_UP, then count.
import random
random.seed(2103)
P_UP = 0.5
print("sign-sampling of critical points, P(upward) = 0.5:")
for n in (2, 10, 100, 1000):
    trials = 10000 if n <= 100 else 2000
    mins = 0
    neg_total = 0
    for _ in range(trials):
        neg = sum(1 for _ in range(n) if random.random() > P_UP)
        neg_total += neg
        if neg == 0:
            mins += 1
    p_theory = P_UP ** n
    print(f"  n = {n:>5}: local minima {mins:>5}/{trials} (theory p^n = {p_theory:.2e}), "
          f"mean negative directions {neg_total / trials:.1f} of {n}")
print("\nAs dimension grows, minima vanish exponentially while negative directions")
print("multiply: the generic critical point of a high-dimensional landscape is a saddle.")

The sampled counts track the theory as it collapses: 2,439 of 10,000 sampled critical points are local minima at n = 2 (theory 2.50e-01), 13 at n = 10 (9.77e-04), and not one in 10,000 at n = 100 (7.89e-31). By n = 1000 the probability is 9.33e-302 and the sampled mean negative direction count has climbed to 499.9 of 1000. The 0.5 coin is a simplification - real landscapes are not symmetric - but the exponential shape is the point, and it is Dauphin et al.'s abstract verbatim: "a deeper and more profound difficulty originates from the proliferation of saddle points, not local minima, especially in high dimensional problems". A hundred-million-parameter model has no local minima to speak of; it has saddles with hundreds of downward directions, surrounded by the plateaus that eat training time.

The folklore's other half gets its own correction. Choromanska et al. (arXiv 1412.0233) model the loss surfaces of multilayer networks with spin-glass tools and conjecture that SGD lands in "the band of low critical points, and that all critical points found there are local minima of high quality measured by the test error". Read together: the minima gradient descent does find are mostly good ones, the bad ones are exponentially rare, and the real tax is the saddle plateaus in between - which is why Section 5's inertia, not a minimum-hunting algorithm, is the standard fix.


Convexity: When Any Local Minimum Is the Answer

Convexity is the one setting where local-search anxiety is unfounded, and the second-derivative test is its receipt. A function is convex exactly when its second derivative never goes negative - every chord sits above the graph - and on a convex surface every local minimum is the global minimum, full stop. The asymmetric double well shows the test refusing a function that looks harmless.

# Convex: every local minimum is THE global minimum. The second-derivative
# test reads it off a dense grid; the asymmetric double well refuses it.
def f(x):
    return (x * x - 1.0) ** 2 + 0.3 * x

def df(x):
    return 4.0 * x * (x * x - 1.0) + 0.3

def d2f(x):
    return 12.0 * x * x - 4.0

N = 4001
xs = [-3.0 + 6.0 * i / (N - 1) for i in range(N)]
neg = sum(1 for x in xs if d2f(x) < 0.0)
print("double well f = (x^2 - 1)^2 + 0.3x on [-3, 3]:")
print(f"  grid points with f'' < 0: {neg} of {N} -> NOT convex")
a, b = -1.5, -0.5
for _ in range(200):
    m = 0.5 * (a + b)
    if df(a) * df(m) <= 0.0:
        b = m
    else:
        a = m
x_deep = 0.5 * (a + b)
a, b = 0.5, 1.5
for _ in range(200):
    m = 0.5 * (a + b)
    if df(a) * df(m) <= 0.0:
        b = m
    else:
        a = m
x_shallow = 0.5 * (a + b)
print(f"  deep minimum    x = {x_deep:+.4f}  f = {f(x_deep):+.4f}")
print(f"  shallow minimum x = {x_shallow:+.4f}  f = {f(x_shallow):+.4f}")
print(f"  quality gap: {f(x_shallow) - f(x_deep):.4f} - the landscape, not the "
      "optimizer, set the ranking")
print("convex control x^2: f'' = 2 everywhere, single minimum at 0 - global "
      "by convexity")

The double well fails convexity on 769 of the 4,001 grid points - the region between its wells curves downward - and the failure has teeth: its deep minimum at x = -1.0356 sits at f = -0.3054 while the shallow one at x = +0.9601 sits at f = +0.2941, a quality gap of 0.5996 set entirely by the landscape's asymmetry (the +0.3x tilt). That tilt is the honest picture of a real loss surface: basins of different quality, and an optimizer with no map. Convexity removes the anxiety by guaranteeing there is only one basin; deep networks live on the other side of that guarantee, and Section 3's geometry - minima mostly good, saddles the real obstacle - is what makes the non-convex side livable.


The Optimizer Campaign: Momentum as Inertia

Momentum is the standard answer to the flat-direction trap, and the physics is literal: it adds a velocity accumulator, so the update is a heavy ball rolling on the landscape rather than a point dragged downhill. 5501 owns the update-rule family (heavy ball, LARS, LAMB); this campaign is the why. One asymmetric double well, 1,000 random starts, two optimizers, identical step budget.

# One landscape, 1,000 random starts, two optimizers. Plain GD settles in
# the basin it lands in; momentum's inertia carries starts through the
# barrier top at x = 0 into the deep well.
import random
random.seed(2103)

def df(x):
    return 4.0 * x * (x * x - 1.0) + 0.3

ETA, STEPS = 0.004, 800
BETA = 0.90

def gd():
    x = random.uniform(-2.0, 2.0)
    for _ in range(STEPS):
        x -= ETA * df(x)
    return x

def momentum():
    x = random.uniform(-2.0, 2.0)
    v = 0.0
    for _ in range(STEPS):
        v = BETA * v - ETA * df(x)
        x += v
    return x

row = {}
for name, fn in (("plain GD", gd), ("GD + momentum (b = 0.90)", momentum)):
    deep = shallow = stuck = 0
    for _ in range(1000):
        x = fn()
        if abs(x) < 1.5:
            if x < 0.0:
                deep += 1
            else:
                shallow += 1
        else:
            stuck += 1
    row[name] = (deep, shallow, stuck)
    print(f"{name:<26} deep {deep:>4}/1000   shallow {shallow:>4}/1000   "
          f"unconverged {stuck:>3}/1000")
gd_deep, gd_shallow, _ = row["plain GD"]
m_deep, m_shallow, _ = row["GD + momentum (b = 0.90)"]
print(f"\nmomentum moves {gd_shallow - m_shallow} of plain GD's {gd_shallow} "
      "shallow-basin starts into the deep well")
print("inertia is not noise: it is the landscape read at speed - Goh's "
      "'barrel through narrow valleys, small humps and local minima'")

Plain GD splits the starts down the middle of the landscape: 505 deep, 495 shallow, none unconverged - it takes the basin it lands in and stays, exactly the Section 4 picture. Adding the beta = 0.90 accumulator moves the outcome to 533 deep against 467 shallow: 28 of plain GD's 495 shallow-basin starts arrived with enough downhill speed to roll over the barrier at x = 0 that plain GD could not cross. The winner-quality gap those 28 crossings buy is the Section 4 gap of 0.5996 per moved start. Goh's Distill article (2017) names the mechanism in one sentence: "The added inertia acts both as a smoother and an accelerator, dampening oscillations and causing us to barrel through narrow valleys, small humps and local minima." The same inertia is also why momentum needs care on high-curvature axes - the 1 - eta * lambda factors of Section 1 now ring at their own frequency - which is the practical bridge to 5501's tuned variants.


Summary

The second derivative is not bookkeeping after the gradient - it is the shape of the surface the gradient walks. This lesson read the Hessian as geometry: signs classify critical points, curvatures price gradient descent's per-axis step factors 1 - eta * lambda, and the condition number (4.0 for the lesson's bowl) explains why flat directions, not steep ones, eat the wall clock. The saddle walked apart into its two halves - a repelling direction escaped by step 25 and a flat direction needing 1,151 steps - and Newton's method landed on the saddle itself in one step, the failure the saddle-free Newton fix exists for. The counting argument made high dimensions saddle country: minima fall from 2,439 of 10,000 at n = 2 to zero at n = 100 while mean negative directions climb to 50, with convexity (769 of 4,001 points failing the test on the double well, a 0.5996 quality gap between its minima) marking the one world where local search needs no defense. The campaign closed the loop: momentum carried 28 of 495 shallow-basin starts across the barrier - inertia reading the landscape at speed. The rule it leaves: when a loss curve stalls, ask which direction is flat before asking what is wrong with the optimizer.

References

External References


Next Steps


Related: