Module contents
Lesson 23 of 27Advanced 110 min

The nonconvex reality: saddle points, negative curvature and benign landscapes

Study realistic guarantees for nonconvex optimization, including saddle points, perturbed gradient descent, benign landscapes and the PL condition in overparameterized models.

After this lesson you can

  • Explain why general nonconvex optimization is intractable and identify realistic first- and second-order stationarity guarantees.
  • Define the strict saddle property and explain why small-step GD avoids strict saddles from almost every initialization.
  • Implement perturbed GD and measure its escape time against plain GD near a saddle.
  • Prove that rank-one symmetric factorization has no spurious local minima.
  • Explain how overparameterization induces the PL condition and why SGD converges linearly in the interpolation regime.

Before you start

Motivation: networks are nonconvex and yet they train

All the module’s convergence theory rests, in one way or another, on convexity: the O(1/k)\bigO(1/k) rate of GD, Nesterov acceleration, dual certificates. A neural network’s loss is not convex, not because of a technical detail but for a structural reason visible in the smallest possible example: a two-layer, one-neuron linear “network”, f(a,b)=abf(a, b) = ab, fitted to datum y=1y = 1 with squared loss,

L(a,b)=(ab−1)2.\Loss(a, b) = (ab - 1)^2.

Its global minimizers form the hyperbola ab=1ab = 1, which has two branches. The midpoint of (1,1)(1, 1) and (−1,−1)(-1, -1) is the origin, where L=1\Loss = 1. Since the set of minimizers of a convex function is convex, L\Loss cannot be convex. The origin is also a critical point: ∇L(a,b)=2(ab−1)(b,a)\grad\Loss(a, b) = 2(ab - 1)(b, a) vanishes at (0,0)(0, 0), and its Hessian there is [0−2−20]\begin{bmatrix} 0 & -2 \\ -2 & 0 \end{bmatrix}, with eigenvalues ±2\pm 2. It is a saddle.

The same happens in any network. Permuting a layer’s hidden neurons (and the corresponding weight rows and columns) does not change the function computed by the network, so every global minimum is accompanied by its h!h! permuted copies, and the segment joining two of them often passes through worse configurations. A real network has an astronomical number of these symmetries, and between two isolated minima separated by a barrier the mountain pass theorem guarantees (under compactness conditions) a critical point that is not a minimum.

Yet SGD trains networks with billions of parameters reliably. This lesson studies why that is not a miracle, and how far what can be proved goes:

  • The impossible. Deciding whether a point is a local minimum is already NP-hard in general. We must settle for more modest goals: first- and second-order stationary points.
  • The real obstacle. In high dimension, high-loss critical points are almost always saddles, not bad minima.
  • Saddles are not traps. GD does not converge to a strict saddle except from a measure-zero set, although it may take a long time to leave; with perturbations it escapes in polynomial time.
  • Benign landscapes. Important nonconvex problems (factorization, PCA, matrix completion) have no spurious local minima.
  • Overparameterization. In sufficiently wide networks, with many more parameters than data, the loss satisfies the Polyak–Łojasiewicz condition near initialization, and GD and SGD converge linearly.

What cannot be guaranteed

In lesson 8 you saw that GD with step 1/L1/L finds a point with ∥∇f∥≤ε\norm{\grad f} \le \varepsilon in O(1/ε2)\bigO(1/\varepsilon^2) iterations without any convexity: the nonconvex stationarity result. But a stationary point may be a minimum, saddle or maximum. Can we ask for more? Can we at least check whether the point reached is a local minimum?

In general, no. Recall the classification of critical points: if the Hessian is positive definite, the point is a strict minimum; if it has a negative eigenvalue, it is not a minimum. The problem lies in the semidefinite case, where second-order conditions decide nothing and higher orders must be examined. The extreme case is a homogeneous degree-4 polynomial, whose gradient and Hessian at the origin vanish.

Proof

There are three steps.

Local minimum equals copositivity. fMf_{\mat{M}} is homogeneous of degree 4, fM(tx)=t4fM(x)f_{\mat{M}}(t\vb{x}) = t^4 f_{\mat{M}}(\vb{x}), so 0\vb{0} is a local minimum if and only if fM≥0f_{\mat{M}} \ge 0 for every Rn\R^n (if it were negative at some x\vb{x}, it would be negative at txt\vb{x} with arbitrarily small tt). With z=(x12,…,xn2)\vb{z} = (x_1^2, \dots, x_n^2), which ranges over the entire orthant z≥0\vb{z} \ge \vb{0}, this says z⊤Mz≥0\vb{z}\T\mat{M}\vb{z} \ge 0 for all z≥0\vb{z} \ge \vb{0}: that M\mat{M} is copositive.

Copositivity and cliques. Let GG be a graph with adjacency matrix A\mat{A} and clique number ω(G)\omega(G) (the size of its largest clique). The Motzkin–Straus theorem (1965) says max⁡x∈Δx⊤Ax=1−1/ω(G)\max_{\vb{x} \in \Delta}\vb{x}\T\mat{A}\vb{x} = 1 - 1/\omega(G) on the simplex Δ={x≥0, ∑ixi=1}\Delta = \{\vb{x} \ge \vb{0},\ \sum_i x_i = 1\}. With B=J−A\mat{B} = \mat{J} - \mat{A} (J\mat{J} is the all-ones matrix) and using x⊤Jx=1\vb{x}\T\mat{J}\vb{x} = 1 on Δ\Delta, this is min⁡Δx⊤Bx=1/ω(G)\min_{\Delta}\vb{x}\T\mat{B}\vb{x} = 1/\omega(G). Take Mk=kB−J\mat{M}_k = k\mat{B} - \mat{J}. On the simplex, x⊤Mkx=k x⊤Bx−1\vb{x}\T\mat{M}_k\vb{x} = k\,\vb{x}\T\mat{B}\vb{x} - 1, and by homogeneity it suffices to consider the simplex:

Mk copositiva  ⟺  min⁡Δx⊤Bx≥1k  ⟺  ω(G)≤k.\mat{M}_k \text{ copositiva} \iff \min_\Delta \vb{x}\T\mat{B}\vb{x} \ge \tfrac1k \iff \omega(G) \le k.

Reduction. CLIQUE, deciding whether ω(G)≥k+1\omega(G) \ge k + 1, is NP-complete, and G↦MkG \mapsto \mat{M}_k is a polynomial reduction from CLIQUE to deciding that 0\vb{0} is not a local minimum of fMkf_{\mat{M}_k}. The problem is in NP because a rational z≥0\vb{z} \ge \vb{0} with z⊤Mz<0\vb{z}\T\mat{M}\vb{z} < 0 is a verifiable certificate, and one of polynomial size exists: the minimizer of z⊤Mz\vb{z}\T\mat{M}\vb{z} on the simplex is attained in the relative interior of a face, where it solves a linear system with the data of M\mat{M}.

∎

Murty and Kabadi’s original reduction starts from SUBSET SUM; the one above, via the Motzkin–Straus theorem, is shorter and gives the same result.

The cell constructs a graph with ω(G)=3\omega(G) = 3 (a hexagon with two chords forming two triangles) and checks both sides of the equivalence. With k=2k = 2, the triangle indicator witnesses that M2\mat{M}_2 is not copositive, and ff is negative along curve tzt\sqrt{\vb{z}} however small tt is. With k=3k = 3, the value on the triangle is exactly 0 and the sampled minimum is positive; but note that sampling never proves copositivity: this asymmetry between finding a witness and certifying its absence is exactly that of NP versus co-NP.

[ ]Copositivity: an unseen local minimumBrowser
import itertools
import numpy as np

n = 6
aristas = [(i, (i + 1) % n) for i in range(n)] + [(0, 2), (3, 5)]   # C6 y dos cuerdas: triángulos {0,1,2} y {3,4,5}
A = np.zeros((n, n))
for i, j in aristas:
    A[i, j] = A[j, i] = 1

def omega(A):
    """Número de clique por fuerza bruta (exponencial: solo para grafos diminutos)."""
    m = len(A)
    return max(r for r in range(1, m + 1) for S in itertools.combinations(range(m), r)
               if all(A[i, j] for i, j in itertools.combinations(S, 2)))

B = np.ones((n, n)) - A                       # J − A
w = omega(A)
rng = np.random.default_rng(0)
Z = rng.dirichlet(0.3 * np.ones(n), size=200_000)            # puntos del símplex
print(f"ω(G) = {w};  mín. muestreado de xᵀBx en el símplex = {np.einsum('si,ij,sj->s', Z, B, Z).min():.4f}  (1/ω = {1/w:.4f})")

def f(x, M):                                  # f(x) = Σ M_ij x_i² x_j²: gradiente y hessiano nulos en 0
    z = x * x
    return z @ M @ z

tri = np.array([1, 1, 1, 0, 0, 0]) / 3        # indicadora del triángulo {0, 1, 2}
for k in (2, 3):
    M = k * B - np.ones((n, n))
    pmin = np.einsum('si,ij,sj->s', Z, M, Z).min()
    print(f"k = {k}: zᵀMz en el triángulo = {tri @ M @ tri:+.4f};  mín. muestreado = {pmin:+.4f};  "
          f"f(t·√z) con t = 1e-3: {f(1e-3 * np.sqrt(tri), M):+.2e}")

The practical consequence is clear: no efficient algorithm can guarantee local minima in general (unless P = NP), much less global ones. What we can ask for is what the gradient and Hessian measure.

First- and second-order stationarity

The scale ρε\sqrt{\rho\varepsilon} is not arbitrary: it is the only combination of ρ\rho (units of ff per length cubed) and ε\varepsilon (units of ff per length) with curvature units. With it the definition is invariant to rescaling ff and the result is natural: a local minimum x⋆\vb{x}^\star satisfies both conditions with ε=0\varepsilon = 0, and near it they hold with small ε\varepsilon. The converse fails only in degenerate cases, and excluding them requires an assumption about ff.

The robust version divides space into three regions, each with a progress argument: gradient descent in the first, negative-curvature descent in the second and local linear convergence in the third. Under it, a second-order ε\varepsilon-point with sufficiently small ε\varepsilon must be near a local minimum.

Three examples clarify the ideas:

  • (ab−1)2(ab - 1)^2 at the origin: Hessian with eigenvalues ±2\pm 2. Strict saddle.
  • x2−y4x^2 - y^4 at the origin: Hessian diag⁡(2,0)\diag(2, 0), positive semidefinite. Passes the second-order test and is not a minimum (f(0,y)=−y4<0f(0, y) = -y^4 < 0). Non-strict saddle.
  • The monkey saddle x3−3xy2x^3 - 3xy^2: gradient and Hessian vanish at the origin. Three valleys and three ridges that no second-order test distinguishes from a minimum.

Non-strict saddles are exactly where the difficulty in Murty and Kabadi’s theorem lies, and they must be excluded by assumption.

Saddles everywhere: the high-dimensional argument

Why worry more about saddles than bad local minima? Because in high dimension they are overwhelmingly more numerous. The naive argument: at a “generic” critical point the Hessian has nn eigenvalues, and to be a minimum they must all be positive. If their signs were independent coins, the probability would be 2−n2^{-n}. Reality is even more extreme, because eigenvalues of a random matrix repel one another: for the GOE matrix (symmetric with Gaussian entries), Dean and Majumdar (2006) calculated that

P(todos los autovalores de Hn son positivos)≈e−θn2,θ=ln⁡34≈0.275,\Pr\big(\text{todos los autovalores de } \mat{H}_n \text{ son positivos}\big) \approx e^{-\theta n^2}, \qquad \theta = \tfrac{\ln 3}{4} \approx 0.275,

which decays as e−n2e^{-n^2}, not 2−n2^{-n}. With n=1000n = 1000 parameters, e−0.275⋅106e^{-0.275\cdot 10^6} is so small that no conceivable sampling would find a minimum “at random.”

The argument becomes quantitative in a concrete model. In an isotropic Gaussian field f:Rn→Rf : \R^n \to \R, Bray and Dean (2007) calculated that, conditional on x\vb{x} being a critical point with value f(x)=εf(\vb{x}) = \varepsilon, the Hessian is a GOE matrix shifted in proportion to ε\varepsilon. When n→∞n \to \infty its spectrum fills a semicircle of fixed radius centered at m(ε)m(\varepsilon), a decreasing function of ε\varepsilon. The critical point’s index α\alpha, the fraction of negative eigenvalues, is then the mass of the semicircle to the left of 0:

α(ε)=Fsc(−m(ε)),Fsc(x)=12+1π(x4−x24+arcsin⁡x2)\alpha(\varepsilon) = F_{\mathrm{sc}}\big(-m(\varepsilon)\big), \qquad F_{\mathrm{sc}}(x) = \frac12 + \frac{1}{\pi}\Big(\frac{x\sqrt{4 - x^2}}{4} + \arcsin\frac{x}{2}\Big)

for the radius-2 semicircle. The important conclusion is that the index grows with loss. High-loss critical points are saddles with many escape directions; index-zero points (minima) concentrate in a narrow band near the bottom, where the entire semicircle has moved to the right of zero.

InteractiveIndex of critical points
Height ε\varepsilon versus index α\alpha of 140 critical points
ε = 1/6
Hessian spectrum at selected point and semicircle shifted to m(ε)=3(1−2ε)m(\varepsilon) = 3(1 - 2\varepsilon)
curvatura negativa
  • critical point (saddle)
  • minimum (index 0)
  • semicircle prediction
  • selected
Landscape
Dimension n
height ε of selected pointn/a
observed index αn/a
theoretical index (n → ∞)n/a
P(minimum) at that heightn/a
if signs were coin flips, 2⁻ⁿ7.9e−31
Each point is a critical point, with index α\alpha (fraction of negative Hessian eigenvalues) horizontally and loss vertically. In ‘Random field’, Hessians are GOE matrices of dimension nn shifted by m(ε)=3(1−2ε)m(\varepsilon) = 3(1 - 2\varepsilon) (heights normalized to [0,1][0, 1]; the particular shift is a scale choice), and the index is calculated exactly by Sturm count. Increase nn: the cloud hugs the theoretical curve and minima only appear below ε=1/6\varepsilon = 1/6. Click a point to see its spectrum. In ‘Linear network’ all critical points of ∥UU⊤−M∥F2\norm{\mat{U}\mat{U}\T - \mat{M}}_F^2 appear, calculated exactly: a single minimum and, the greater the loss, the more escape directions.

Empirical evidence in real networks points the same way. Dauphin, Pascanu, Gulcehre, Cho, Ganguli and Bengio (2014) located critical points of small perceptrons trained on reduced versions of MNIST and CIFAR-10 (using Newton’s method, which, as we will see, is attracted to saddles) and observed a monotonic relation between training error and index, as in the figure. Choromanska, Henaff, Mathieu, Ben Arous and LeCun (2015) obtained the same structure in multilayer ReLU networks after reducing them to a spherical spin glass, with independence assumptions the authors themselves recognize as unrealistic.

An exact case: the linear network

The factorization f(U)=∥UU⊤−M∥F2f(\mat{U}) = \norm{\mat{U}\mat{U}\T - \mat{M}}_F^2 with U∈Rn×k\mat{U} \in \R^{n\times k} is a two-layer linear network with tied weights (a linear autoencoder), and its critical points are known exactly. With M=∑iλivivi⊤\mat{M} = \sum_i \lambda_i\vb{v}_i\vb{v}_i\T, λ1>⋯>λn>0\lambda_1 > \cdots > \lambda_n > 0:

  • critical points are, up to rotations U↦UQ\mat{U} \mapsto \mat{U}\mat{Q}, matrices whose columns are λi vi\sqrt{\lambda_i}\,\vb{v}_i for a subset SS of indices with ∣S∣≤k\abs{S} \le k (and zero columns to fill up to kk);
  • their loss is ∑i∉Sλi2\sum_{i \notin S}\lambda_i^2;
  • their index, the number of negative Hessian eigenvalues, is
ind⁡(S)=∑i∈S#{j∉S:λj>λi}+(k−∣S∣)(n−∣S∣).\operatorname{ind}(S) = \sum_{i \in S}\#\{j \notin S : \lambda_j > \lambda_i\} + (k - \abs{S})(n - \abs{S}).

Each term counts an escape: swap a chosen direction for a better missing one, or fill an empty column with any missing direction. The only critical point with no exits is S={1,…,k}S = \{1, \dots, k\}, the global minimum. You will verify the formula numerically, with a critical-point finder and the Hessian, in the implementation section. This is the pattern of Baldi and Hornik (1989) for linear autoencoders and the archetype of what we call a benign landscape.

GD avoids strict saddles almost surely

Begin with the quadratic, where everything is explicit. For f(x)=12x⊤Hxf(\vb{x}) = \tfrac12\vb{x}\T\mat{H}\vb{x} with H=∑iλivivi⊤\mat{H} = \sum_i\lambda_i\vb{v}_i\vb{v}_i\T, GD with step η\eta is the linear iteration xk+1=(I−ηH)xk\vb{x}_{k+1} = (\mat{I} - \eta\mat{H})\vb{x}_k analyzed in GD on quadratics, and in the eigenvector basis

⟨xk,vi⟩=(1−ηλi)k ⟨x0,vi⟩.\inner{\vb{x}_k}{\vb{v}_i} = (1 - \eta\lambda_i)^k\,\inner{\vb{x}_0}{\vb{v}_i}.

If λi>0\lambda_i > 0 and η<1/λmax⁡\eta < 1/\lambda_{\max}, the component contracts; if λi<0\lambda_i < 0, it grows as (1+η∣λi∣)k(1 + \eta\abs{\lambda_i})^k. GD converges to saddle 0\vb{0} if and only if x0\vb{x}_0 has no component in negative- or zero-curvature directions: if x0\vb{x}_0 is in subspace Es=span⁡{vi:λi>0}E^s = \spn\{\vb{v}_i : \lambda_i > 0\}, the saddle’s stable manifold. If λmin⁡<0\lambda_{\min} < 0, EsE^s has dimension less than nn and zero Lebesgue measure.

For a general ff, near a critical point GD resembles its linearization, and the tool converting that intuition into a theorem is stability by linearization of dynamical systems, applied to the fixed-point iteration xk+1=g(xk)\vb{x}_{k+1} = g(\vb{x}_k) with g(x)=x−η∇f(x)g(\vb{x}) = \vb{x} - \eta\grad f(\vb{x}).

Proof

gg is an injective local diffeomorphism. Its differential is I−η∇2f(x)\mat{I} - \eta\hess f(\vb{x}), with eigenvalues ≥1−ηL>0\ge 1 - \eta L > 0, hence invertible everywhere. And gg is injective: if g(x)=g(y)g(\vb{x}) = g(\vb{y}), then x−y=η(∇f(x)−∇f(y))\vb{x} - \vb{y} = \eta(\grad f(\vb{x}) - \grad f(\vb{y})) and ∥x−y∥≤ηL∥x−y∥\norm{\vb{x} - \vb{y}} \le \eta L\norm{\vb{x} - \vb{y}}, which with ηL<1\eta L < 1 forces x=y\vb{x} = \vb{y}. In particular, the preimage under gg (and gkg^k) of a null set is null.

Local stable manifold. At a strict saddle x⋆\vb{x}^\star, Dg(x⋆)=I−η∇2f(x⋆)\mat{D}g(\vb{x}^\star) = \mat{I} - \eta\hess f(\vb{x}^\star) has eigenvalue 1−ηλmin⁡>11 - \eta\lambda_{\min} > 1. The center-stable manifold theorem gives a neighborhood BB of x⋆\vb{x}^\star and a submanifold WW of dimension equal to the number of eigenvalues of modulus ≤1\le 1 (less than nn, hence measure zero) containing every point whose future orbit remains in BB.

Globalization. If xk→x⋆\vb{x}_k \to \vb{x}^\star, there exists KK with xk∈B\vb{x}_k \in B for every k≥Kk \ge K, so gK(x0)∈Wg^K(\vb{x}_0) \in W and x0∈⋃K≥0g−K(W)\vb{x}_0 \in \bigcup_{K \ge 0} g^{-K}(W): a countable union of null sets. If there are infinitely many saddles, cover them with countably many neighborhoods BB (every subset of Rn\R^n is Lindelöf) and repeat the argument.

∎

Lee et al. proved the result for isolated saddles; the globalization step for infinitely many non-isolated saddles is due to Panageas and Piliouras.

This result is reassuring and misleading at the same time. It says GD eventually escapes every strict saddle, but not when. In the quadratic, if x0\vb{x}_0 has component c0≠0c_0 \ne 0 in the curvature direction −γ-\gamma, escaping to distance RR costs

k≈ln⁡(R/∣c0∣)ln⁡(1+ηγ)≈1ηγln⁡R∣c0∣k \approx \frac{\ln(R/\abs{c_0})}{\ln(1 + \eta\gamma)} \approx \frac{1}{\eta\gamma}\ln\frac{R}{\abs{c_0}}

iterations, an unbounded quantity as c0→0c_0 \to 0. And the situation can be much worse: Du, Jin, Lee, Jordan, Singh and Póczos (2017) constructed smooth functions in Rd\R^d with a chain of dd saddles where each leaves GD near the stable manifold of the next; with reasonable random initialization, GD takes time exponential in dd to escape them all.

InteractiveEscape a saddle
stable manifold (y = 0)yxminimumsaddle
iteration 200
f(xk)−f⋆f(\vb{x}_k) - f^\star per iteration (log scale): the plateau is the saddle
value at the saddle
  • GD
  • Perturbed GD (circle: perturbation)
  • saddle stable manifold
−8
0.50
0.050
Dimension d
iteration k200 / 200
GD: escapes at> 200
GD prediction≈ 190
PGD: escapes at> 200
PGD perturbations before escape0
Far from the stable manifold, GD already escapes quickly and perturbation adds nothing. Lower log⁡10∣y0∣\log_{10}|y_0| or select “y0=0y_0 = 0”.
fγ(x,y)=∥x∥2−γy2+y4/4f_\gamma(\vb{x}, y) = \norm{\vb{x}}^2 - \gamma y^2 + y^4/4 has a strict saddle at the origin, whose stable manifold is y=0y = 0, and minima at y=±2γy = \pm\sqrt{2\gamma}. GD (blue) and perturbed GD (orange, with a circle at each perturbation) start at (1.8,y0)(1.8, y_0) with η=0.1\eta = 0.1. Play the animation, lower log⁡10∣y0∣\log_{10}\abs{y_0} and observe how the GD plateau in the lower plot grows by about ln⁡10/ln⁡(1+2ηγ)\ln 10/\ln(1 + 2\eta\gamma) iterations per decimal digit, while perturbed GD's does not change (the later sawtooth pattern comes from perturbations PGD keeps giving at the minimum, from which it promptly returns). Set y0=0y_0 = 0: GD converges to the saddle. Increase dimension dd (the horizontal axis draws ±∥x∥\pm\norm{\vb{x}}, which with yy determines ff) and press ‘Measure 200 trials’: perturbed GD escape grows only as log⁡d\log d.

Perturbed GD: escaping in polynomial time

The figure suggests the remedy. If the problem near a saddle is a tiny unstable component, give it a reasonable size: add noise when the gradient is small. Jin, Ge, Netrapalli, Kakade and Jordan (2017) turned this into an algorithm with guarantees.

Far from stationary points PGD is GD. Near one, the perturbation is a bet: if the point is (almost) a local minimum, the perturbation barely raises ff and GD returns; if it is a saddle, with high probability the perturbation falls outside a narrow strip around the stable manifold and negative curvature amplifies it. The time taken by this escape from saddle points can be precisely bounded in the quadratic model, and the bound makes the general case work.

Proof

Component ck=⟨xk,v1⟩c_k = \inner{\vb{x}_k}{\vb{v}_1} evolves as ck=(1+ηγ)kc0c_k = (1 + \eta\gamma)^k c_0, with c0=⟨xˉ,v1⟩+ξ1c_0 = \inner{\bar{\vb{x}}}{\vb{v}_1} + \xi_1 and ξ1=⟨ξ,v1⟩\xi_1 = \inner{\vb{\xi}}{\vb{v}_1}. The density of ξ1\xi_1, the marginal of one coordinate of the uniform ball, is

p(t)=cdr(1−t2r2)(d−1)/2,cd=Γ(d/2+1)π Γ(d/2+1/2)≤d+22π,p(t) = \frac{c_d}{r}\Big(1 - \frac{t^2}{r^2}\Big)^{(d - 1)/2}, \qquad c_d = \frac{\Gamma(d/2 + 1)}{\sqrt{\pi}\,\Gamma(d/2 + 1/2)} \le \sqrt{\frac{d + 2}{2\pi}},

where the bound is Gautschi’s inequality, Γ(x+1)/Γ(x+12)<(x+1)1/2\Gamma(x + 1)/\Gamma(x + \tfrac12) < (x + 1)^{1/2}. Since p≤cd/rp \le c_d/r, for any s>0s > 0 the “strip” event ∣c0∣<s\abs{c_0} < s, that is, ξ1∈(−⟨xˉ,v1⟩−s, −⟨xˉ,v1⟩+s)\xi_1 \in (-\inner{\bar{\vb{x}}}{\vb{v}_1} - s,\ -\inner{\bar{\vb{x}}}{\vb{v}_1} + s), has probability ≤2s cd/r\le 2s\,c_d/r. Choose s=δr/(2cd)s = \delta r/(2c_d): outside the strip, ∣ck∣≥(1+ηγ)ks≥R\abs{c_k} \ge (1 + \eta\gamma)^k s \ge R as soon as k≥ln⁡(R/s)/ln⁡(1+ηγ)k \ge \ln(R/s)/\ln(1 + \eta\gamma), and R/s=2cdR/(δr)≤Rδr2(d+2)/πR/s = 2c_d R/(\delta r) \le \frac{R}{\delta r}\sqrt{2(d + 2)/\pi}.

∎

Notice both dependencies. In δ\delta and dd the bound is logarithmic: the dangerous strip has width O(δr/d)\bigO(\delta r/\sqrt{d}) in a ball of radius rr, and its probability is small even when dimension is enormous. And it does not depend on xˉ\bar{\vb{x}} at all: even if GD has arrived exactly at the stable manifold, a single perturbation suffices. This is what “Measure 200 trials” in the figure measures: from d=2d = 2 to d=1000d = 1000 mean escape goes from about 64 to about 94 iterations.

In a nonquadratic ff, the Hessian changes along the path and the strip ceases to be a strip. Jin et al.’s argument replaces it with coupling: if two perturbed points differ by r0v1r_0\vb{v}_1, the difference between their trajectories grows as (1+ηγ)t(1 + \eta\gamma)^t while both remain near the saddle (quadratic approximation error is controlled with ρ\rho), so at least one escapes. Therefore the set of perturbations that stay stuck has width less than r0r_0 in direction v1\vb{v}_1: it is a thin “pancake” and its relative volume in the ball is O(r0d/r)\bigO(r_0\sqrt{d}/r).

Up to logarithms, this is the same number of iterations GD needs for a first-order point. Escaping saddles is almost free. Combined with the strict-saddle property, the theorem gives convergence to a local minimum in polynomial time. Three comments place it in context:

  • SGD already has noise. Ge, Huang, Jin and Yuan (2015) proved that SGD escapes strict saddles in polynomial time if isotropic noise is added to each stochastic gradient. Daneshmand, Kohler, Lucchi and Hofmann (2018) showed that adding it is not even necessary: it suffices that the intrinsic minibatch noise of SGD has nonzero variance along negative-curvature directions, as observed in practice.
  • Newton is attracted to saddles. Near a saddle, the Newton step −∇2f−1∇f-\hess f\inv\grad f points toward the critical point in every direction, including negative-curvature directions: on a quadratic it jumps exactly to the saddle. Dauphin et al. used it precisely to find them, and proposed saddle-free Newton, which uses ∣∇2f∣\abs{\hess f} (absolute eigenvalues) to reverse the direction in negative components.
  • Second order with guarantees. Cubic regularization of Newton (Nesterov and Polyak, 2006) and trust-region methods find ε\varepsilon-stationary second-order points in O(ε−3/2)\bigO(\varepsilon^{-3/2}) iterations, each more expensive.

Benign landscapes

Escaping saddles solves half the problem. The other half is bad local minima, and there is no generic algorithm for them. What does exist is a class of problems where they do not occur.

With the previous two sections the consequence is immediate: in a benign landscape, small-step GD converges to a global minimum for almost every initialization (Lee et al.), and PGD does so in polynomial time if the strict-saddle property is robust (Jin et al.). The basic example is symmetric rank-one factorization.

There are two key calculations. Expanding, f(u)=∥u∥4−2u⊤Mu+∥M∥F2f(\vb{u}) = \norm{\vb{u}}^4 - 2\vb{u}\T\mat{M}\vb{u} + \norm{\mat{M}}_F^2, hence

∇f(u)=4(∥u∥2u−Mu),∇2f(u)=4(∥u∥2I+2uu⊤−M).\grad f(\vb{u}) = 4\big(\norm{\vb{u}}^2\vb{u} - \mat{M}\vb{u}\big), \qquad \hess f(\vb{u}) = 4\big(\norm{\vb{u}}^2\mat{I} + 2\vb{u}\vb{u}\T - \mat{M}\big).

Condition ∇f=0\grad f = \vb{0} is an eigenvector equation: Mu=∥u∥2u\mat{M}\vb{u} = \norm{\vb{u}}^2\vb{u}. And at each bad critical point there is an explicit escape direction, v1\vb{v}_1: at λi vi\sqrt{\lambda_i}\,\vb{v}_i with λi<λ1\lambda_i < \lambda_1, curvature is v1⊤∇2f v1=4(λi−λ1)<0\vb{v}_1\T\hess f\,\vb{v}_1 = 4(\lambda_i - \lambda_1) < 0; at the origin, −4λ1<0-4\lambda_1 < 0. You will give the complete proof in the first guided exercise.

InteractiveA nonconvex landscape without traps
  • global minimum
  • strict saddle
  • local maximum
  • GD trajectory
Critical points: local maximum, global minimum, strict saddle. In 3D, height is normalized log⁡(1+f−f⋆)\log(1 + f - f^\star).
1.20
0.50
29°
M=[1.040.290.290.66]\mat{M} = \begin{bmatrix} 1.04 & 0.29 \\ 0.29 & 0.66 \end{bmatrix}
min. Hessian eigenvalue at the origin−4.80
same at saddle ±√λ₂ v₂−2.80
same at minimum ±√λ₁ v₁2.80
trajectories at a global minimum3 / 3
All trajectories end at a global minimum. The saddles ±λ2 v2\pm\sqrt{\lambda_2}\,\vb{v}_2 have curvature 4(λ2−λ1)=−2.804(\lambda_2 - \lambda_1) = −2.80 along v1\vb{v}_1: they are reached only from their stable manifold, the ray joining them to the origin.
The loss f(u)=∥uu⊤−M∥F2f(\vb{u}) = \norm{\vb{u}\vb{u}\T - \mat{M}}_F^2 for u∈R2\vb{u} \in \R^2. Left: the surface (rotate it), with height log⁡(1+f−f⋆)\log(1 + f - f^\star), an increasing transformation preserving critical points and their type; right: contours. Aqua: the two global minima ±λ1 v1\pm\sqrt{\lambda_1}\,\vb{v}_1; orange: strict saddles; red: the origin when it is a maximum. Run GD from any point (click) or 20 at random: all end at a global minimum. Bring λ2\lambda_2 close to λ1\lambda_1 and watch the saddles lose negative curvature; at λ1=λ2\lambda_1 = \lambda_2, the minima form a circle.

The same phenomenon, with more work, appears in real problems:

  • PCA. Maximizing the Rayleigh quotient u⊤Mu\vb{u}\T\mat{M}\vb{u} over the unit sphere is nonconvex, but by the spectral theorem its critical points are unit eigenvectors and only the leading one (and its opposite) is a local maximum; at all others there is a second-order ascent direction, toward ±v1\pm\vb{v}_1, as in the previous theorem’s strict saddles. The rank-kk version is the linear network of the preceding section.
  • Matrix sensing and completion. Recovering a low-rank matrix from linear measurements satisfying the restricted isometry property (Bhojanapalli, Neyshabur and Srebro, 2016), or from a random sample of entries with a suitable regularizer (Ge, Lee and Ma, 2016), has, with high probability, a landscape without spurious local minima.
  • Phase retrieval and deep linear networks. Sun, Qu and Wright (2018) proved phase retrieval with enough Gaussian measurements is benign. In deep linear networks, Kawaguchi (2016) proved every local minimum is global, although from two hidden layers onward non-strict saddles appear, without negative eigenvalues.

Overparameterization, the PL condition and interpolation

There is another way to guarantee convergence without convexity that does not require describing all critical points: the PL condition, 12∥∇f(x)∥2≥μ (f(x)−f⋆)\tfrac12\norm{\grad f(\vb{x})}^2 \ge \mu\,(f(\vb{x}) - f^\star), under which GD converges linearly (lesson 8). A network with hidden layers does not satisfy it everywhere (it has saddles, like the origin of (ab−1)2(ab - 1)^2, where the gradient vanishes but the loss does not), but wide networks satisfy it near their initialization, and that suffices.

Write the squared loss of a model F:Rp→RnF : \R^p \to \R^n (the nn predictions as a function of pp parameters) as L(w)=12n∥F(w)−y∥2\Loss(\vb{w}) = \frac{1}{2n}\norm{F(\vb{w}) - \vb{y}}^2, with residual r=F(w)−y\vb{r} = F(\vb{w}) - \vb{y}, Jacobian J=DF(w)∈Rn×p\mat{J} = \mat{D}F(\vb{w}) \in \R^{n\times p} and tangent kernel

K(w)=1nJJ⊤∈Rn×n.\mat{K}(\vb{w}) = \tfrac1n\mat{J}\mat{J}\T \in \R^{n\times n}.
Proof

∇L=1nJ⊤r\grad\Loss = \frac1n\mat{J}\T\vb{r}, hence ∥∇L∥2=1n2r⊤JJ⊤r=1nr⊤Kr≥1nλmin⁡(K)∥r∥2=2λmin⁡(K) L\norm{\grad\Loss}^2 = \frac{1}{n^2}\vb{r}\T\mat{J}\mat{J}\T\vb{r} = \frac1n\vb{r}\T\mat{K}\vb{r} \ge \frac1n\lambda_{\min}(\mat{K})\norm{\vb{r}}^2 = 2\lambda_{\min}(\mat{K})\,\Loss.

∎

This is the PL condition induced by overparameterization: if λmin⁡(K)≥μ>0\lambda_{\min}(\mat{K}) \ge \mu > 0 in a region, L\Loss satisfies PL there with constant μ\mu and with f⋆=0f^\star = 0 (Liu, Zhu and Belkin call it PL*). The lemma explains why more parameters than data are needed: K\mat{K} has rank at most pp, so if p<np < n is singular, λmin⁡(K)=0\lambda_{\min}(\mat{K}) = 0 and there is no guarantee. With p≥np \ge n the kernel can be positive definite, though counting is not enough: it must remain well-conditioned along the whole path.

Proof

By induction, suppose w0,…,wt∈B\vb{w}_0, \dots, \vb{w}_t \in B. The descent lemma with η=1/β\eta = 1/\beta and the previous lemma give L(ws+1)≤L(ws)−12β∥∇L(ws)∥2≤(1−μ/β)L(ws)\Loss(\vb{w}_{s+1}) \le \Loss(\vb{w}_s) - \frac{1}{2\beta}\norm{\grad\Loss(\vb{w}_s)}^2 \le (1 - \mu/\beta)\Loss(\vb{w}_s) for s≤ts \le t, yielding the rate. For path length: since L≥0\Loss \ge 0 is β\beta-smooth, ∥∇L(w)∥2≤2βL(w)\norm{\grad\Loss(\vb{w})}^2 \le 2\beta\Loss(\vb{w}) (apply the descent lemma at w−∇L(w)/β\vb{w} - \grad\Loss(\vb{w})/\beta and use L≥0\Loss \ge 0). Then, with q=1−μ/βq = \sqrt{1 - \mu/\beta},

∥wt+1−w0∥≤∑s=0t∥∇L(ws)∥β≤2L(w0)β∑s≥0qs=2L(w0)β 11−q≤2L(w0)β 2βμ=ϱ,\norm{\vb{w}_{t+1} - \vb{w}_0} \le \sum_{s=0}^{t}\frac{\norm{\grad\Loss(\vb{w}_s)}}{\beta} \le \sqrt{\frac{2\Loss(\vb{w}_0)}{\beta}}\sum_{s \ge 0} q^s = \sqrt{\frac{2\Loss(\vb{w}_0)}{\beta}}\,\frac{1}{1 - q} \le \sqrt{\frac{2\Loss(\vb{w}_0)}{\beta}}\,\frac{2\beta}{\mu} = \varrho,

using 1−1−x≥x/21 - \sqrt{1 - x} \ge x/2. Thus wt+1∈B\vb{w}_{t+1} \in B and induction closes. The same sum shows (wt)(\vb{w}_t) is Cauchy; its limit lies in BB (closed) and makes L\Loss vanish by continuity.

∎

It remains to see why wide networks satisfy the hypothesis. With the usual parametrization of tangent-kernel analyses (outputs scaled by 1/m1/\sqrt{m}, with mm the width), model Hessian FF has norm O~(1/m)\tilde{\bigO}(1/\sqrt{m}) in fixed-radius balls (Liu, Zhu and Belkin, 2020), so K(w)\mat{K}(\vb{w}) barely moves in BB. If at initialization λmin⁡(K(w0))≥2μ\lambda_{\min}(\mat{K}(\vb{w}_0)) \ge 2\mu, which happens with high probability for distinct inputs and large mm, the hypothesis holds throughout the ball. Radius ϱ\varrho does not grow with mm; what improves with width is the constancy of K\mat{K}.

InteractiveOverparameterization helps optimization
Training loss L(wk)L(\vb{w}_k) (log scale) for each width
Data and width 64 network: initial and final
PL constant during training: estimated 12∥∇L∥2/L\tfrac12\norm{\grad L}^2/L and its bound λmin⁡(K)\lambda_{\min}(\mat{K}) (log scale)
  • m = 1
  • m = 2
  • m = 4
  • m = 8
  • m = 16
  • m = 64 (selected)
  • m = 256
  • λ_min(K), lower bound on the PL constant
  • initial network
Width m (hidden neurons)
Algorithm
parameters / data points192 / 8
final lossn/a
observed per-step factor (second half)n/a
min. λ_min(K) along trajectoryn/a
min. observed ½‖∇L‖²/Ln/a
Seven f(x)=m−1/2∑jajtanh⁡(wjx+bj)f(x) = m^{-1/2}\sum_j a_j\tanh(w_j x + b_j) networks of width mm (with 3m3m parameters) train with GD on the same 8 data points. With m=1m = 1 or 22 there are fewer parameters than data: K\mat{K} is singular, estimated PL constant 12∥∇L∥2/L\tfrac12\norm{\grad\Loss}^2/\Loss collapses and loss stalls. With m=64m = 64 or 256256, λmin⁡(K)\lambda_{\min}(\mat{K}) (dashed) stays away from 0 throughout training and loss falls in a straight line on a log scale, as the theorem predicts. Choose each width and notice the intermediate ones: more parameters than data does not guarantee a good kernel. Switch to SGD: with constant step, convergence remains linear in wide networks.

SGD in the interpolation regime

The figure shows something that appears to contradict what was learned in convex SGD convergence: SGD with constant step converging linearly to zero loss, without any noise floor. The reason is the solution structure.

In the interpolation regime, ∇fi(x⋆)=0\grad f_i(\vb{x}^\star) = \vb{0} for each ii, so stochastic-gradient variance vanishes at the solution. Quantitatively, if each fif_i is Lmax⁡L_{\max}-smooth and nonnegative with minimum 0, ∥∇fi(x)∥2≤2Lmax⁡fi(x)\norm{\grad f_i(\vb{x})}^2 \le 2L_{\max}f_i(\vb{x}), and averaging gives

Ei∥∇fi(x)∥2≤2Lmax⁡ f(x).\E_i\norm{\grad f_i(\vb{x})}^2 \le 2L_{\max}\,f(\vb{x}).

Noise is proportional to the loss, not a constant σ2\sigma^2. That is why there is no need to reduce the step: noise switches itself off.

The proof is four lines from the descent lemma and you will reconstruct it in the second guided exercise. The constant is not the best possible: finer analyses (Ma, Bassily and Belkin, 2018) permit, in quadratic problems, steps of order 1/Lmax⁡1/L_{\max} and quantitatively explain the benefit of minibatches up to a critical size. But the qualitative conclusion is what matters: in the interpolation regime, constant-step SGD converges linearly like GD, and according to Ma et al. a step with a critical-sized minibatch advances almost as much as a GD step at a fraction of its cost. Compare this with general nonconvex SGD convergence from lesson 19, which only guaranteed stationarity with decreasing steps.

Implementation from scratch

First, the race in the figure: GD versus perturbed GD on fγf_\gamma, measuring escape time as a function of initial distance to the stable manifold and comparing it with prediction ln⁡(γ/∣y0∣)/ln⁡(1+2ηγ)\ln(\sqrt{\gamma}/\abs{y_0})/\ln(1 + 2\eta\gamma).

[ ]GD and perturbed GD near a saddleBrowser
import numpy as np

gam, eta = 0.5, 0.1

def grad(z):
    """f(x, y) = ‖x‖² − γy² + y⁴/4 con z = (x₁, ..., x_{d−1}, y): silla estricta en 0, mínimos en y = ±√(2γ)."""
    g = 2 * z.copy()
    g[-1] = -2 * gam * z[-1] + z[-1] ** 3
    return g

def escapo(z):
    return abs(z[-1]) >= np.sqrt(gam)

def gd(z0, max_iter=100_000):
    z = z0.copy()
    for k in range(max_iter):
        if escapo(z):
            return k
        z -= eta * grad(z)
    return None

def pgd(z0, rng, radius=0.05, g_thresh=0.05, t_wait=25, max_iter=100_000):
    z, ultimo, d = z0.copy(), -t_wait, len(z0)
    for k in range(max_iter):
        if escapo(z):
            return k
        if np.linalg.norm(grad(z)) <= g_thresh and k - ultimo >= t_wait:
            u = rng.standard_normal(d)
            z += radius * rng.random() ** (1 / d) * u / np.linalg.norm(u)   # uniforme en la bola
            ultimo = k
        z -= eta * grad(z)
    return None

rng = np.random.default_rng(0)
print("  |y0|      GD   predicción   PGD")
for p in (2, 4, 8, 12, 16):
    z0 = np.array([1.8, 10.0 ** -p])
    pred = np.log(np.sqrt(gam) * 10.0 ** p) / np.log(1 + 2 * eta * gam)
    print(f"  1e-{p:<4d} {gd(z0):5d} {pred:9.0f} {pgd(z0, rng):7d}")
print("  y0 = 0:  GD tras 5000 iteraciones:", gd(np.array([1.8, 0.0]), max_iter=5000), "   PGD:", pgd(np.array([1.8, 0.0]), rng))

GD takes about 24 more iterations per decimal digit of ∣y0∣\abs{y_0} (it is ln⁡10/ln⁡1.1\ln 10/\ln 1.1), and the linear prediction is accurate except for a few iterations: those at the beginning, when ∣y∣\abs{y} does not yet dominate, and the final push of term y4/4y^4/4. PGD escapes in time independent of y0y_0. Now, the dimension dependence predicted by the proposition:

[ ]PGD escape as a function of dimensionBrowser
for d in (2, 10, 100, 1000):
    z0 = np.zeros(d)
    z0[0] = 1.8
    ts = np.array([pgd(z0, rng) for _ in range(100)])
    print(f"d = {d:5d}: escape medio {ts.mean():5.1f} iteraciones, percentil 95: {np.percentile(ts, 95):5.1f}")

Multiplying dimension by 10 adds about 10 iterations, on the order of ln⁡10/ln⁡1.1≈12\ln\sqrt{10}/\ln 1.1 \approx 12: the perturbation component in the unstable direction is of order r/dr/\sqrt{d}, and escaping it costs a logarithm.

Rank-kk factorization is benign. Run it from 40 random initializations at once and verify that all reach optimal value f⋆=∑i>kλi2f^\star = \sum_{i > k}\lambda_i^2:

[ ]Low-rank factorization from random initializationsBrowser
rng = np.random.default_rng(1)
n, k, ensayos = 30, 3, 40
Q, _ = np.linalg.qr(rng.standard_normal((n, n)))
lam = np.r_[5.0, 3.0, 2.0, rng.uniform(0, 1, n - 3)]          # semidefinida positiva, hueco tras el tercero
M = (Q * lam) @ Q.T
f_opt = np.sum(np.sort(lam)[:-k] ** 2)                       # ‖M‖² − (λ₁² + λ₂² + λ₃²)

U = rng.standard_normal((ensayos, n, k)) * 0.3              # 40 inicializaciones a la vez
for it in range(2000):
    R = U @ U.transpose(0, 2, 1) - M                         # UUᵀ − M en cada ensayo
    U -= 0.01 * 4 * R @ U
gap = np.sum((U @ U.transpose(0, 2, 1) - M) ** 2, axis=(1, 2)) - f_opt
print(f"f(U) − f* tras 2000 pasos, en {ensayos} inicializaciones: máx = {gap.max():.1e}, mín = {gap.min():.1e}")

Hessian spectrum at critical points

Now a miniature Dauphin et al. lab, on linear network f(U)=∥UU⊤−M∥F2f(\mat{U}) = \norm{\mat{U}\mat{U}\T - \mat{M}}_F^2 with U∈R6×2\mat{U} \in \R^{6\times 2}: locate critical points by minimizing 12∥∇f∥2\tfrac12\norm{\grad f}^2 (with Levenberg–Marquardt: the residual is ∇f\grad f and its Jacobian is the Hessian), measure their index and compare with the exact formula. The Hessian is never formed from hand-written second derivatives: everything comes from the Hessian-vector product, the directional derivative of the gradient,

∇2f(U)[D]=4(DU⊤+UD⊤)U+4(UU⊤−M)D,\hess f(\mat{U})[\mat{D}] = 4(\mat{D}\mat{U}\T + \mat{U}\mat{D}\T)\mat{U} + 4(\mat{U}\mat{U}\T - \mat{M})\mat{D},

which is all that can be calculated in a large network. Using it, the Lanczos algorithm estimates extreme eigenvalues without forming the matrix.

[ ]Critical points of a linear network: search, index and LanczosBrowser
n, k = 6, 2
lam = np.array([6.0, 5, 4, 3, 2, 1])
M = np.diag(lam)
P = n * k

def f_lin(U):
    return np.sum((U @ U.T - M) ** 2)

def grad_lin(U):
    return 4 * (U @ U.T - M) @ U

def hvp(U, D):
    """Producto hessiano-vector exacto: derivada direccional de 4(UUᵀ − M)U en la dirección D."""
    return 4 * (D @ U.T + U @ D.T) @ U + 4 * (U @ U.T - M) @ D

def hessiano(U):
    return np.array([hvp(U, e.reshape(n, k)).ravel() for e in np.eye(P)])

def lanczos(matvec, dim, m, rng):
    """m pasos de Lanczos con reortogonalización completa; devuelve los valores de Ritz."""
    Q = np.zeros((m + 1, dim))
    alpha, beta = np.zeros(m), np.zeros(m)
    q = rng.standard_normal(dim)
    Q[0] = q / np.linalg.norm(q)
    for j in range(m):
        w = matvec(Q[j])
        alpha[j] = w @ Q[j]
        w -= Q[: j + 1].T @ (Q[: j + 1] @ w)
        beta[j] = np.linalg.norm(w)
        if beta[j] < 1e-12:
            m = j + 1
            break
        Q[j + 1] = w / beta[j]
    T = np.diag(alpha[:m]) + np.diag(beta[: m - 1], 1) + np.diag(beta[: m - 1], -1)
    return np.linalg.eigvalsh(T)

def buscar_critico(U, iters=50, mu=1e-3):
    """Minimiza ½‖∇f‖² por Levenberg-Marquardt."""
    for _ in range(iters):
        g, H = grad_lin(U).ravel(), hessiano(U)
        if np.linalg.norm(g) < 1e-12:
            break
        for _ in range(30):
            Un = U - np.linalg.solve(H @ H + mu * np.eye(P), H @ g).reshape(n, k)
            if np.linalg.norm(grad_lin(Un)) < np.linalg.norm(g):
                U, mu = Un, max(mu / 3, 1e-14)
                break
            mu *= 4
        else:
            break
    return U, np.linalg.norm(grad_lin(U))

def indice_formula(S):
    fuera = [j for j in range(n) if j not in S]
    return sum(sum(lam[j] > lam[i] for j in fuera) for i in S) + (k - len(S)) * len(fuera)

rng = np.random.default_rng(0)
vistos = {}
for _ in range(60):
    U, gn = buscar_critico(rng.standard_normal((n, k)) * rng.uniform(0.3, 2))
    if gn > 1e-9:
        continue
    S = tuple(i for i in range(n) if (U @ U.T)[i, i] > lam[i] / 2)    # autovectores elegidos
    ev = np.linalg.eigvalsh(hessiano(U))
    ritz = lanczos(lambda v: hvp(U, v.reshape(n, k)).ravel(), P, 10, rng)
    vistos[S] = (f_lin(U), int((ev < -1e-6).sum()), indice_formula(S), ev.min(), ritz.min())
print(f"{len(vistos)} puntos críticos distintos (salvo rotaciones) en 60 búsquedas")
print("  S          pérdida  índice  fórmula   λ_min    λ_min con Lanczos (10 pasos)")
for S, (fv, idx, fo, lm, lr) in sorted(vistos.items(), key=lambda kv: kv[1][0]):
    print(f"  {str(S):10s} {fv:6.1f} {idx:6d} {fo:7d} {lm:9.3f} {lr:12.3f}")

The search finds critical points of almost all types (minimizing ∥∇f∥2\norm{\grad f}^2 is indifferent to type, like Newton’s method), and the measured index matches the formula in all cases. The table, ordered by loss, reproduces the random-matrix model trend: more loss, more escape directions. Two cautions about the technique. Here, with 10 steps in 12 dimensions, Lanczos gives almost exact λmin⁡\lambda_{\min}; in a real network a few dozen steps are used in millions of dimensions, and precision depends on separation of the extreme from the rest of the spectrum. And Lanczos with one initial vector does not see multiplicities: a Krylov space holds a single vector from each eigenspace, so counting negative eigenvalues with its Ritz values underestimates the index when eigenvalues repeat, as here. The index needs the full spectrum, block Lanczos, or an estimate of spectral density.

Finally, the coin comparison: the probability that a GOE matrix n×nn\times n is positive definite, by Monte Carlo, versus 2−n2^{-n}.

[ ]How many saddles: GOE versus coinsBrowser
rng = np.random.default_rng(0)
print(" n   P(todos > 0)    ln P / n²    2^(−n)")
for n_ in range(1, 6):
    A_ = rng.standard_normal((100_000, n_, n_))
    p = (np.linalg.eigvalsh((A_ + A_.transpose(0, 2, 1)) / 2)[:, 0] > 0).mean()
    print(f" {n_}   {p:.2e}       {np.log(p) / n_**2:+.3f}      {2.0**-n_:.2e}")

Already at n=5n = 5 the probability is about 180 times lower than 2−52^{-5}, and ln⁡P/n2\ln P/n^2 slowly approaches limit −ln⁡3/4≈−0.275-\ln 3/4 \approx -0.275 (corrections are of order 1/n1/n).

Width, tangent kernel and linear convergence

The network from the last figure, in NumPy: train several widths with GD and measure λmin⁡(K)\lambda_{\min}(\mat{K}) along the path.

[ ]Width and the PL constantBrowser
N = 8
X = np.linspace(-1, 1, N)
Y = np.sin(3 * X) + 0.4 * np.random.default_rng(3).standard_normal(N)

def entrena(m, pasos=1500, eta=1.5, sgd=False, seed=0):
    """Red f(x) = m^(−1/2) Σ a_j tanh(w_j x + b_j); devuelve las pérdidas y λ_min(K) cada 100 pasos."""
    rng = np.random.default_rng(seed)
    w, b, a = 8 * rng.standard_normal(m), rng.uniform(-8, 8, m), rng.standard_normal(m)
    s = 1 / np.sqrt(m)
    perdidas, lmins = [], []
    for t in range(pasos + 1):
        H = np.tanh(np.outer(X, w) + b)                       # (N, m)
        r = s * H @ a - Y
        perdidas.append(0.5 * np.mean(r ** 2))
        D = s * (1 - H ** 2) * a                              # ∂f/∂b_j en cada dato
        J = np.hstack([D * X[:, None], D, s * H])             # jacobiano (N, 3m)
        if t % 100 == 0:
            lmins.append(np.linalg.eigvalsh(J @ J.T / N)[0])
        if t == pasos:
            break
        if sgd:
            i = rng.integers(N)
            paso = J[i] * r[i]
        else:
            paso = J.T @ r / N
        w, b, a = w - eta * paso[:m], b - eta * paso[m:2 * m], a - eta * paso[2 * m:]
    return np.array(perdidas), np.array(lmins)

print("   m  parámetros   L(0)       L(750)     L(1500)    mín λ_min(K)")
for m in (2, 8, 64, 256):
    L, lm = entrena(m)
    print(f"{m:4d} {3 * m:8d}     {L[0]:.2e}   {L[750]:.2e}   {L[-1]:.2e}   {max(lm.min(), 0):.1e}")

With m=2m = 2 the kernel is singular and the loss stays at 0.350.35; with m=256m = 256, λmin⁡(K)≈5×10−3\lambda_{\min}(\mat{K}) \approx 5\times 10^{-3} and loss falls many orders of magnitude. And SGD with one example per step and constant step, in a narrow and a wide network:

[ ]Constant-step SGD, with and without interpolationBrowser
for m in (2, 256):
    L, _ = entrena(m, pasos=3000, eta=1.0, sgd=True)
    print(f"m = {m:3d}:  L(1000) = {L[1000]:.1e}   L(2000) = {L[2000]:.1e}   L(3000) = {L[3000]:.1e}")

In the wide network, which interpolates, loss falls linearly with constant step; in the narrow one, which cannot interpolate, SGD bounces around a positive loss.

The library version

In a real network nobody forms the Hessian. Automatic differentiation libraries calculate Hessian-vector products in two passes (forward over the gradient, or double backpropagation), costing on the order of two gradients, and scipy.sparse.linalg.eigsh runs Lanczos on a LinearOperator. The following snippet does in PyTorch what the linear network cell does, on the tiny tanh network from the preceding note. It is reference code, not an executable cell: in a real network it would run on the GPU (with device="cuda" on tensors, as in device placement), and the dynamic autograd graph allows the gradient to be differentiated again.

import numpy as np
import torch
from torch.func import grad, hessian, jvp
from scipy.sparse.linalg import LinearOperator, eigsh

dt = torch.float64
X = torch.linspace(-1, 1, 8, dtype=dt)
Y = torch.sin(3 * X) + 0.4 * torch.tensor(np.random.default_rng(3).standard_normal(8), dtype=dt)
h = 4
P = 3 * h + 1

def loss(t):
    w, b, a, c = t[:h], t[h:2 * h], t[2 * h:3 * h], t[3 * h]
    return 0.5 * ((torch.tanh(X[:, None] * w + b) @ a + c - Y) ** 2).mean()

g_fn = grad(loss)

def hvp(t, v):                       # derivada direccional del gradiente: H v sin formar H
    return jvp(g_fn, (t,), (v,))[1]

def lanczos_smallest(t, k=6):
    op = LinearOperator((P, P), dtype=np.float64,
                        matvec=lambda v: hvp(t, torch.as_tensor(v.ravel(), dtype=dt)).numpy())
    return eigsh(op, k=k, which="SA", tol=1e-10, return_eigenvectors=False)

# Con t_c un punto crítico (por ejemplo, el que devuelve Levenberg-Marquardt sobre ½‖∇f‖²):
# lanczos_smallest(t_c) coincide con los menores valores de torch.linalg.eigvalsh(hessian(loss)(t_c)).

For large networks, the standard tool is stochastic Lanczos quadrature, which estimates the full Hessian spectral density from a few dozen Lanczos steps with random vectors (implemented, for example, in PyHessian). You will see it applied in the next lesson.

Common mistakes

Three common mistakes in this subject have already appeared where appropriate: treating a plateau as a local minimum, extrapolating benign landscapes to general deep networks, and confusing overparameterization with good generalization. The fourth appears as soon as curvature is measured in a real network.

Exercises

NumericHow long GD takes to escape
In f(x,y)=x2−y2f(x, y) = x^2 - y^2, GD with η=0.1\eta = 0.1 starts at (1,10−8)(1, 10^{-8}). How many iterations are needed for ∣yk∣\abs{y_k} to exceed 1 for the first time?
NumericCurvature of a factorization saddle
For f(u)=∥uu⊤−M∥F2f(\vb{u}) = \norm{\vb{u}\vb{u}\T - \mat{M}}_F^2 with M=diag⁡(3,1)\mat{M} = \diag(3, 1), point u=(0,1)\vb{u} = (0, 1) is critical. What is the smallest eigenvalue of the Hessian at that point?
NumericIterations with a wide network's PL constant
A wide network satisfies λmin⁡(K)≥μ=0.5\lambda_{\min}(\mat{K}) \ge \mu = 0.5 on the theorem's ball, and its loss is β\beta-smooth with β=4\beta = 4. With GD and η=1/β\eta = 1/\beta, how many iterations does the theorem guarantee to reduce loss by a factor 10610^6?
QuizWhat experiments do not prove
In large networks, training from hundreds of random initializations almost always gives similar low training losses. Why does that observation not prove there are no bad local minima? (Several answers may be correct.)

More than one answer may be correct.

QuizNewton near a saddle
Near a strict saddle x⋆\vb{x}^\star of a function with invertible Hessian, what does the pure Newton step x←x−∇2f(x)−1∇f(x)\vb{x} \leftarrow \vb{x} - \hess f(\vb{x})\inv\grad f(\vb{x}) do?
QuizDiagnosing a plateau
Training loss has been nearly flat at a high value for 2000 steps. Using Lanczos on the whole training set, you calculate λmin⁡(∇2f)≈−0.3\lambda_{\min}(\hess f) \approx -0.3 and λmax⁡≈50\lambda_{\max} \approx 50. What is most reasonable?
ProofRank-one factorization is benign
Prove: Let M\mat{M} be symmetric positive semidefinite and nonzero, with eigenvalues λ1≥⋯≥λn≥0\lambda_1 \ge \cdots \ge \lambda_n \ge 0 and orthonormal eigenvectors vi\vb{v}_i, and f(u)=∥uu⊤−M∥F2f(\vb{u}) = \norm{\vb{u}\vb{u}\T - \mat{M}}_F^2. Every local minimum of ff is global and every other critical point is a strict saddle.
0
Expand f(u)=∥u∥4−2u⊤Mu+∥M∥F2f(\vb{u}) = \norm{\vb{u}}^4 - 2\vb{u}\T\mat{M}\vb{u} + \norm{\mat{M}}_F^2.

Step 1 of 4. What are the critical points?

ProofLinear SGD under PL and interpolation
Prove: Let f=1n∑ifif = \frac1n\sum_i f_i with fi≥0f_i \ge 0 Lmax⁡L_{\max}-smooth and fi(x⋆)=0f_i(\vb{x}^\star) = 0 for all ii (interpolation), ff LL-smooth and μ\mu-PL with f⋆=0f^\star = 0. SGD xk+1=xk−η∇fik(xk)\vb{x}_{k+1} = \vb{x}_k - \eta\grad f_{i_k}(\vb{x}_k), with uniform iki_k, and η=μ/(LLmax⁡)\eta = \mu/(L L_{\max}) satisfies Ef(xk)≤(1−μ2/(LLmax⁡))kf(x0)\E f(\vb{x}_k) \le (1 - \mu^2/(L L_{\max}))^k f(\vb{x}_0).
0
Fix xk\vb{x}_k and write g=∇fik(xk)\vb{g} = \grad f_{i_k}(\vb{x}_k).

Step 1 of 4. Which inequality do you start from?

CodeImplement perturbed GD
Implement perturbed_gd(grad, x0, eta, radius, g_thresh, t_wait, n_iter, rng), returning (x, kicks): the final iterate and the list of iterations at which perturbation occurred. At each iteration k = 0, ..., n_iter - 1: if ∥∇f(x)∥≤\norm{\grad f(\vb{x})} \le g_thresh and there has never been a perturbation or at least t_wait iterations have passed since the last, add to x a uniform point in the ball of radius radius (generate the direction with rng.standard_normal and the radius with rng.random) and record k; then take step x = x - eta * grad(x).
import numpy as np

def perturbed_gd(grad, x0, eta, radius, g_thresh, t_wait, n_iter, rng):
  x = np.array(x0, dtype=float)
  kicks = []
  for k in range(n_iter):
      # tu código: perturbación uniforme en la bola cuando el gradiente es pequeño
      x = x - eta * grad(x)
  return x, kicks
Shift+Enter to run

Summary

Key idea
In nonconvex problems a global minimum cannot be demanded, nor even a local one certified; but in high dimension the typical obstacle is saddles, which GD avoids almost surely and perturbed GD escapes in polynomial time, and there are whole classes of problems (benign landscapes, overparameterized models satisfying PL near initialization) in which first-order methods find the global optimum.
  • Verifying that a point is a local minimum is NP-hard (Murty and Kabadi): at the origin of a quartic, local minimality equals copositivity, which encodes CLIQUE. Realistic targets are first-order (∥∇f∥≤ε\norm{\grad f} \le \varepsilon) and second-order (λmin⁡(∇2f)≥−ρε\lambda_{\min}(\hess f) \ge -\sqrt{\rho\varepsilon}) stationary points.
  • A strict saddle has λmin⁡(∇2f)<0\lambda_{\min}(\hess f) < 0. If all saddles are strict, second-order points are local minima; degenerate saddles (x2−y4x^2 - y^4, the monkey saddle) are what must be excluded.
  • In high dimension, high-loss critical points are saddles: in a Gaussian field the index grows with loss, and the probability that a GOE Hessian is positive definite decays as e−n2ln⁡3/4e^{-n^2\ln 3/4}.
  • GD with η<1/L\eta < 1/L converges to a strict saddle only from a measure-zero set (Lee et al.), but escape time grows as ln⁡(1/∣c0∣)/(ηγ)\ln(1/\abs{c_0})/(\eta\gamma) with distance ∣c0∣\abs{c_0} to the stable manifold, and may be exponential in dd. Perturbed GD escapes with probability 1−δ1 - \delta in time logarithmic in dd and 1/δ1/\delta, and finds second-order points in O~(ℓΔf/ε2)\tilde{\bigO}(\ell\Delta_f/\varepsilon^2) iterations (Jin et al.).
  • A landscape is benign if every local minimum is global and every other critical point is a strict saddle. Factorization ∥uu⊤−M∥F2\norm{\vb{u}\vb{u}\T - \mat{M}}_F^2, PCA, matrix sensing and completion are benign; general nonlinear networks are not.
  • With more parameters than data, 12∥∇L∥2≥λmin⁡(K)L\tfrac12\norm{\grad\Loss}^2 \ge \lambda_{\min}(\mat{K})\Loss with tangent kernel K=JJ⊤/n\mat{K} = \mat{J}\mat{J}\T/n. If λmin⁡(K)≥μ\lambda_{\min}(\mat{K}) \ge \mu in a ball of radius 22βL0/μ2\sqrt{2\beta\Loss_0}/\mu, GD converges linearly to zero loss; in wide networks K\mat{K} barely changes and the hypothesis holds.
  • In the interpolation regime SGD noise is proportional to loss, E∥∇fi∥2≤2Lmax⁡f\E\norm{\grad f_i}^2 \le 2L_{\max}f, and constant-step SGD converges linearly under PL. All this concerns optimization, not generalization.