Landscapes and Gradient Descent

Dive into Deep Learning · §9.1

Landscapes and Gradient Descent
ill-conditioned valleys · condition number κ · saddles & plateaus · descent lemma · edge of stability · preconditioning

Why Gradient Descent Crawls or Suddenly Diverges

Motivation

  • Empirical risk minimization: Updating \mathbf{x} \leftarrow \mathbf{x} - \eta \nabla f(\mathbf{x}) in high dimensions (d \gg 10^6) is governed not by bad local minima, but by three geometric properties:
  • 1. Ill-conditioning (\kappa = \lambda_{\max}/\lambda_{\min} \gg 1): Large curvature ratios cap stable step sizes \eta < 2/\lambda_{\max} and starve flat directions.
  • 2. High-dimensional saddles & progressive sharpening: Critical points at high loss are overwhelmingly saddles, and sharpness \lambda_{\max}(\nabla^2 f(\mathbf{x}_t)) climbs dynamically until arresting at 2/\eta.

The Quadratic Valley: Curvatures 0.2 and 4.0

The Quadratic Model

Consider the axis-aligned valley f(\mathbf{x}) = 0.1x_1^2 + 2x_2^2 with gradient \nabla f(\mathbf{x}) = (0.2x_1, 4x_2) and curvatures \lambda_1 = 0.2, \lambda_2 = 4.0:

  • Decoupled multiplicative updates: x_i \leftarrow (1 - \lambda_i \eta)\, x_i
  • Stability ceiling (x_2, \lambda_2 = 4): Contracting |1 - 4\eta| < 1 requires \eta < 0.5.
  • Convergence pace (x_1, \lambda_1 = 0.2): For any stable \eta < 0.5, the flat multiplier satisfies 1 - 0.2\eta > 0.9, removing <10\% of x_1 error per step.
VALLEY_CURVATURES = (0.2, 4.0)
h1, h2 = VALLEY_CURVATURES  # Curvatures of the valley along x1 and x2

def f_valley(x1, x2):
    """The ill-conditioned quadratic valley h1/2 x1^2 + h2/2 x2^2, with
    (h1, h2) = VALLEY_CURVATURES."""
    h1, h2 = VALLEY_CURVATURES
    return h1 / 2 * x1 ** 2 + h2 / 2 * x2 ** 2

def valley_grad(x1, x2):
    """Gradient of f_valley."""
    h1, h2 = VALLEY_CURVATURES
    return h1 * x1, h2 * x2

def train_2d(trainer, f_grad, steps=20, **hparams):
    """Run a 2D update rule from (-5, -2) and return the iterates."""
    x1, x2, s1, s2 = -5, -2, 0, 0  # s1, s2: state of stateful optimizers
    results = [(x1, x2)]
    for _ in range(steps):
        x1, x2, s1, s2 = trainer(x1, x2, s1, s2, f_grad, **hparams)
        results.append((x1, x2))
    print(f'step {steps}, x1: {float(x1):f}, x2: {float(x2):f}')
    return results

def gd_2d(x1, x2, s1, s2, f_grad, eta):
    """One step of gradient descent in 2D; the state stays zero."""
    g1, g2 = f_grad(x1, x2)
    return x1 - eta * g1, x2 - eta * g2, 0, 0

Dynamics at η = 0.45: Steep Oscillation vs. Flat Creep

Valley Trajectory

  • At \eta = 0.45 (just below the stability ceiling 2/\lambda_2 = 0.5), the two coordinates evolve at vastly different rates from (-5, -2):
    • Steep wall (x_2): Multiplier 1 - 4(0.45) = -0.80 flips sign on every step, overshooting the valley floor while shrinking by 20\% per step.
    • Flat floor (x_1): Multiplier 1 - 0.2(0.45) = 0.91 creeps monotonically without sign flips; after 30 steps, x_1 \approx -5 \times 0.91^{30} \approx -0.30.
  • The negative gradient (-1, -8) at (-5, -2) points almost perpendicular to the direction toward the origin.

Balancing Both Axes: Optimal Step Size η* = 0.476

Step-Size Sweep

  • Convergence requires both coordinates to shrink below 1\% of their initial distance: 1 - \lambda_1 \eta^\star = -(1 - \lambda_2 \eta^\star)
  • Solving gives \eta^\star = \frac{2}{\lambda_1 + \lambda_2} = \frac{2}{4.2} \approx 0.476, where both multipliers have magnitude 0.905 and reach 1\% in 47 steps.
  • Sharp cliff above \eta^\star: Dropping slightly below to \eta = 0.45 costs only 2 extra steps (49), whereas pushing slightly above to \eta = 0.49 more than doubles the step count (113 steps).
  eta   factor x1   factor x2   steps to 1%
0.100       0.980       0.600           228
...
0.490       0.902      -0.960           113
0.500       0.900      -1.000         never

General Quadratics and the Condition Number κ

Eigenbasis Analysis

  • Decoupled eigenmodes: For f(\mathbf{x}) = \frac{1}{2}\mathbf{x}^\top \mathbf{H}\mathbf{x} with eigenvalues 0 < \lambda_{\min} \le \cdots \le \lambda_{\max}, each eigenvector \mathbf{v}_i contracts independently by (1 - \eta\lambda_i)^t.
  • Global stability ceiling: Contracting every mode requires |1 - \eta\lambda_i| < 1, bottlenecked by the sharpest mode: \eta < 2/\lambda_{\max}.
  • Condition number \kappa = \lambda_{\max}/\lambda_{\min}: At \eta^\star = \frac{2}{\lambda_{\min} + \lambda_{\max}}, worst-case contraction is \frac{\kappa - 1}{\kappa + 1} \approx 1 - \frac{2}{\kappa}, requiring t \approx \frac{\kappa}{2}\ln\frac{1}{\epsilon} steps.

Critical Points: Why Saddle Points Dominate in High d

Non-Convex Geometry

At any critical point (\nabla f(\mathbf{x}) = \mathbf{0}), the eigenvalues of the Hessian \mathbf{H} = \nabla^2 f(\mathbf{x}) classify local geometry:

  • Local minimum (\mathbf{H} \succ \mathbf{0}): All d eigenvalues strictly positive.
  • Local maximum (\mathbf{H} \prec \mathbf{0}): All d eigenvalues strictly negative.
  • Saddle point: Both positive and negative eigenvalues (e.g., z = x^2 - y^2).
  • Combinatorial rarity of high-loss minima: If eigenvalue signs at high loss behave roughly symmetrically around zero, all d eigenvalues are positive with probability \sim 2^{-d}, so high-loss critical points are overwhelmingly saddle points.

Why Strict Saddle Points Do Not Trap Gradient Descent

Escaping Saddles

  • Exponential repulsion along unstable modes: At a strict saddle with negative eigenvalue \lambda = -\mu < 0, each gradient step amplifies any displacement c_t: c_{t+1} = (1 + \eta\mu)\, c_t
  • Measure-zero stable manifold: Random initializations have nonzero unstable projections with probability 1 (Lee et al., 2016).
  • Logarithmic escape time: Escaping from initial offset \delta > 0 to distance 1 takes only t \approx \frac{\ln(1/\delta)}{\eta\mu} steps—and minibatch noise kicks iterates off the ridge even if \delta = 0.

Activation Plateaus vs. Outlier-Bulk Hessian Spectra

Plateaus & Neural Spectra

  • Activation plateaus: Without any critical point, saturating nonlinearities create vast flat regions—on f(x) = \tanh(x) at x = 4, f'(4) = 1 - \tanh^2(4) \approx 0.0013, so GD at \eta = 1 takes 370 steps just to creep from x = 4 to x = 2.
  • Architectural mitigation: Modern networks eliminate saturation plateaus via ReLU/GELU activations, LayerNorm/BatchNorm, and residual connections.
  • Empirical Hessian spectrum: What remains is severe ill-conditioning: a massive bulk of eigenvalues near zero alongside a few large positive outliers whose maximum (sharpness \lambda_{\max}) caps \eta < 2/\lambda_{\max}.

L-Smoothness and the Descent Lemma

Non-Quadratic Guarantees

  • Quadratic upper bound (L-smoothness): If \|\nabla^2 f(\mathbf{x})\|_2 \le L everywhere, f(\mathbf{x}+\boldsymbol{\epsilon}) \le f(\mathbf{x}) + \boldsymbol{\epsilon}^\top\nabla f(\mathbf{x}) + \frac{L}{2}\|\boldsymbol{\epsilon}\|^2.
  • The Descent Lemma (\boldsymbol{\epsilon} = -\eta\nabla f(\mathbf{x})): f(\mathbf{x} - \eta\nabla f(\mathbf{x})) \le f(\mathbf{x}) - \eta\Big(1 - \frac{\eta L}{2}\Big)\|\nabla f(\mathbf{x})\|^2
  • Guaranteed decrease: Every 0 < \eta < 2/L strictly lowers f, with the largest guaranteed single-step drop \frac{\|\nabla f\|^2}{2L} at \eta = 1/L.

How the Learning Rate Selects Minima by Sharpness

Linear Stability of Minima

  • Curvature filter: Near a minimum x^\star of curvature \lambda = f''(x^\star) > 0, one step multiplies displacement x - x^\star by 1 - \eta\lambda:
    • Stable (\lambda < 2/\eta): |1 - \eta\lambda| < 1 attracts iterates into x^\star.
    • Unstable (\lambda > 2/\eta): 1 - \eta\lambda < -1 ejects iterates out of the basin.
  • On f(x) = x\cos(0.15\pi x): At \eta = 0.5 (2/\eta = 4), both the deep sharp minimum (f'' = 1.81) and shallow flat minimum (f'' = 0.98) are stable; raising \eta = 2.0 (2/\eta = 1) destabilizes the deep minimum (-2.62) and forces convergence to the flat one.

Sharpness Selection in Action: η = 0.5 vs. η = 2.0

Empirical Demonstration

  • Starting from x_0 = 10 on f(x) = x\cos(0.15\pi x):
    • \eta = 0.5 (2/\eta = 4 > 1.81): Rapidly converges into the deep, sharper minimum at x = 7.269.
    • \eta = 2.0 (2/\eta = 1 < 1.81): The deep minimum is unstable (1 - \eta f'' = -2.62), so the iterate is catapulted out of the deep basin and settles in the shallower, flatter minimum at x = -1.821 (f'' = 0.98 < 1).
  • Key principle: The learning rate \eta filters solutions by their curvature (\lambda_{\max} \le 2/\eta), not by their loss depth.

f''(7.27) = 1.81, f''(-1.83) = 0.98
eta 0.5, 2/eta = 4: x = 7.269 after 10 steps, 7.269 after 100
eta 2, 2/eta = 1: x = -1.528 after 10 steps, -1.821 after 100

Progressive Sharpening and the Edge of Stability

Neural Network Dynamics

  • In neural networks trained with full-batch gradient descent, the Hessian sharpness \lambda_{\max}(\nabla^2 f(\mathbf{x}_t)) is not static—it increases steadily as the loss drops (progressive sharpening, Cohen et al., 2021).
  • On a 25-parameter \tanh MLP fitting y = \sin(3x), we compute the exact 25 \times 25 Hessian every 500 steps across 10 random initializations:
    • Normalized sharpness \frac{\lambda_{\max}}{2/\eta} climbs until it hits 1.0 (\lambda_{\max} \approx 2/\eta) and plateaus there for the rest of training.

At the Edge of Stability: Non-Monotonic Descent

Self-Stabilization at 2/η

  • All 10 random initializations: runs at \eta = 0.4 arrest at sharpness \lambda_{\max} \approx 5.0 = 2/0.4; most runs at \eta = 0.25 climb higher, to \lambda_{\max} \approx 8.0 = 2/0.25 (a few fit the data first and stay just below, rising on \approx 0\% of steps).
  • Why doesn’t the run diverge? Once \lambda_{\max} momentarily exceeds 2/\eta, growing oscillation along the sharpest eigenvector (1 - \eta\lambda_{\max} \approx -1, causing loss to rise on \sim 50\% of steps) couples with third derivatives of the loss to push the iterate toward flatter regions (Damian et al., 2023).
      start      |    eta 0.4, 2/eta = 5     |    eta 0.25, 2/eta = 8     
sharpness   loss | sharpness    loss  rising | sharpness    loss  rising 
     2.92  0.540 |      5.00 3.3e-04    50% |      8.00 3.5e-04    50% 
     2.45  0.257 |      5.00 1.9e-03    50% |      7.78 1.0e-04     0% 
     5.18  0.669 |      4.99 3.9e-04    50% |      7.98 1.4e-04    50% 
     3.46  0.323 |      4.99 4.1e-04    50% |      7.98 2.9e-04    49% 
     3.33  0.736 |      4.99 4.2e-04    50% |      8.01 2.0e-04    50% 
     4.62  0.805 |      4.99 3.9e-04    50% |      8.02 1.7e-04    50% 
     2.95  1.170 |      5.01 3.2e-04    50% |      7.98 7.4e-05     0% 
     3.98  1.408 |      5.00 3.0e-04     0% |      8.00 3.9e-04    50% 
     4.06  0.706 |      5.00 2.9e-04    50% |      8.00 2.3e-04     1% 
     3.19  0.376 |      5.00 2.7e-04    50% |      7.98 4.4e-05     0% 

Newton’s Method and Why Exact Hessian Inversion Fails

Second-Order Optimization

  • Newton’s step (\mathbf{x} \leftarrow \mathbf{x} - \mathbf{H}^{-1}\nabla f(\mathbf{x})): Rescales every eigendirection by 1/\lambda_i, collapsing \kappa \to 1 and solving any positive-definite quadratic in 1 step.
  • Why exact Newton steps fail in deep learning:
    1. O(d^2) storage & O(d^3) inversion: \mathbf{H} has 10^{18} entries at d = 10^9.
    2. Saddle attraction: Negative eigenvalues \lambda_i < 0 flip the step sign and drive iterates uphill toward saddles or maxima.
    3. Noise amplification: Inverting tiny noisy curvature estimates explodes minibatch variance.

Diagonal Preconditioning: Rescaling Each Coordinate

Affordable Curvature Scaling

  • Preconditioned gradient descent \mathbf{x} \leftarrow \mathbf{x} - \eta\mathbf{P}^{-1}\nabla f(\mathbf{x}) replaces \mathbf{H} with a cheap O(d) approximation \mathbf{P} that reduces the effective condition number of \mathbf{P}^{-1/2}\mathbf{H}\mathbf{P}^{-1/2}.
  • Diagonal preconditioning (\mathbf{P} = \operatorname{diag}(\mathbf{H})): x_i \leftarrow x_i - \eta\,\frac{\partial_i f(\mathbf{x})}{H_{ii}}
  • On our axis-aligned valley (\operatorname{diag}(\mathbf{H}) = (0.2, 4)), both coordinates contract by 1 - \eta, collapsing \kappa = 20 \to 1 and reaching 1\% error in 7 steps at \eta = 0.5 (0.5^7 \approx 0.0078) instead of 47.
step 100, x1: -0.000225, x2: -0.000090
step 10, x1: -0.004883, x2: -0.001953
steps to 1%: plain at its best rate 47, preconditioned 7

Concept Check: Conditioning, Stability, and Sharpness

Check Your Understanding

Work out the exact numerical answer for each scenario:

  1. Condition number & step count: A quadratic objective has eigenvalues ranging from \lambda_{\min} = 0.05 to \lambda_{\max} = 10. What is the maximum stable learning rate \eta_{\max}, the condition number \kappa, and the approximate steps t \approx \frac{\kappa}{2}\ln(1/\epsilon) to reach \epsilon = e^{-4} \approx 1.8\% error at \eta^\star?
  2. Edge of stability prediction: On the 25-parameter \tanh network, if we run full-batch gradient descent at \eta = 0.5, at what Hessian sharpness \lambda_{\max} will progressive sharpening plateau?
  3. Rotated valley pitfall: If we rotate f(\mathbf{x}) = 0.1x_1^2 + 2x_2^2 by 45^\circ, what are the diagonal entries H_{11}, H_{22} of the rotated Hessian, and what is the condition number after diagonal preconditioning?

Answers:

  1. \eta_{\max} = 2/\lambda_{\max} = 0.2; \kappa = 10 / 0.05 = 200; and t \approx \frac{200}{2} \times 4 = 400 steps.
  2. Sharpness arrests at the stability ceiling \lambda_{\max} \approx 2/\eta = 2/0.5 = 4.0.
  3. At 45^\circ, H_{11} = H_{22} = \frac{0.2 + 4.0}{2} = 2.1 are identical. Dividing by \operatorname{diag}(\mathbf{H}) merely rescales \eta by 1/2.1, leaving \kappa = 20 unchanged, motivating momentum (§9.4) and full-matrix preconditioning (§9.6).

Summary: Landscapes, Conditioning, and Gradient Descent

Key Takeaways

Concept / Phenomenon Mathematical Formula Scaling & Stability Behavior Practical Implication
Quadratic Stability Ceiling \eta < \frac{2}{\lambda_{\max}} Steepest eigenvector flips sign & diverges if \eta\lambda_{\max} \ge 2 Sharpest Hessian outlier caps the global learning rate
Condition Number \kappa \kappa = \frac{\lambda_{\max}}{\lambda_{\min}} \ge 1 Steps to accuracy \epsilon scale as t \approx \frac{\kappa}{2}\log\frac{1}{\epsilon} at \eta^\star = \frac{2}{\lambda_{\min}+\lambda_{\max}} No scalar \eta can accelerate ill-conditioned valleys (\kappa \gg 1)
Strict Saddle Escape c_{t+1} = (1 + \eta\mu)c_t (\lambda = -\mu < 0) Escapes in O(\frac{1}{\eta\mu}\log\frac{1}{\delta}) steps from random init High-dimensional saddles do not trap gradient descent
L-Smooth Descent Lemma \Delta f \le -\eta(1 - \frac{\eta L}{2})\|\nabla f\|^2 Strict decrease for 0 < \eta < 2/L; optimal guaranteed step \eta = 1/L Bounds single-step progress when \|\nabla^2 f(\mathbf{x})\|_2 \le L
Edge of Stability \lambda_{\max}(\nabla^2 f(\mathbf{x}_t)) \to \frac{2}{\eta} Progressive sharpening arrests at 2/\eta with non-monotonic steps Larger \eta selects flatter basins; warmup steers into flat regions
Diagonal Preconditioning \mathbf{x} \leftarrow \mathbf{x} - \eta\,\operatorname{diag}(\mathbf{H})^{-1}\nabla f(\mathbf{x}) Collapses axis-aligned \kappa \to 1 in O(d) memory (47 \to 7 steps) Motivates online coordinate scaling in AdaGrad, RMSProp, and Adam