Nonconvex landscapes: saddle points, sharpness and the edge of stability
Before this lesson: lesson 02 (the descent lemma), lesson 03 (the stability limit ), lesson 05 (SGD noise), lesson 07 (warmup) and lesson 10 (Newton's method). From other tracks: power iteration (linear algebra 05), Lanczos (linear algebra 14) and Hessian-vector products by automatic differentiation (calculus 08). Time: about 85 minutes, plus the notebook. This is a difficult lesson: take the figures one at a time.
Why this matters #
Lessons 01–06 mostly assumed a convex loss with one curvature bound . A neural-network loss is nonconvex, and its curvature changes by orders of magnitude during a run. This lesson answers three practical questions. What can gradient descent promise? A small gradient, not a minimum. Do saddle points stop training? Rarely, but they can slow it down. Which learning rates are stable, and why does training work even when the theory says it should diverge? The answer is the sharpness and the edge of stability. Sharpness is also measured in practice: to debug unstable runs of large models, to explain warmup (lesson 07), and in methods such as SAM that look for flat minima.
1. Predict first #
2. The picture #
Stationary points and the Hessian. A stationary point (or critical point) of is a point with . Near it, , where is the Hessian, the matrix of second derivatives. Write with orthonormal eigenvectors and eigenvalues . Along the function curves up if and down if . So the signs of the eigenvalues give the shape:
| Eigenvalues of | Shape near the point | Name |
|---|---|---|
| all | bowl | strict local minimum |
| all | upside-down bowl | strict local maximum |
| some , some | up in some directions, down in others | saddle point |
| some | the quadratic term is flat in some direction | degenerate: the test cannot decide |
Rotate the surface by dragging it. The surface is aqua where is above and magenta where it is below. The orange and blue curves follow the eigenvectors and of the Hessian. Use the presets for a minimum, a maximum and a saddle. Then set , and try the degenerate functions (a minimum) and (not a minimum): both have the same Hessian at the origin, so the Hessian alone cannot tell them apart.
Gradient descent near a saddle. Take the simplest saddle, . The gradient is , so gradient descent (GD) with step gives
The -coordinate shrinks: is the stable direction. The -coordinate grows by the factor at every step, however small it is at the start. Only a start with exactly converges to the saddle. A start with first moves toward the saddle along , then leaves along .
Make the offset smaller. The gradient-descent path comes closer to the saddle (the cross) and stays near it longer, but it still escapes. The chart shows on a log scale: a straight line with slope , next to the linear estimate (dashed). Each factor 10 in adds the same number of steps. Press δ = 0 exactly: now GD converges to the saddle. Add noise and it escapes again. Show Newton: Newton's method (magenta) jumps to the saddle. Switch to the double well to see the same on a function with two minima.
At a stationary point, the Hessian has the eigenvalues and . What is the point?
One eigenvalue is positive and one is negative, so curves up along one eigenvector and down along the other: a saddle. It is strict because . The test fails only when an eigenvalue is exactly 0 and the others do not already show a direction of descent.
In the saddle figure (), GD needs 145 steps to reach from . About how many steps does it need from ?
, so the escape needs steps. Going from to doubles , so it doubles the steps: . The escape time grows with the logarithm of , not with .
3. Definitions and main results #
Stationary points and the second-order test #
Definitions. Let be twice continuously differentiable. A stationary point has . A strict saddle is a stationary point with . (With this definition, a strict local maximum is also a strict saddle; the important property is that some direction goes down.)
Theorem (second-order conditions).
- Necessary. If is a local minimum, then and .
- Sufficient. If and , then is a strict local minimum.
Proof. By Taylor's theorem, with .
- If , then with small lowers . So . If for some unit , then for small . So .
- With : , and . For small the first term wins, so the difference is positive.
Degenerate cases. When is singular, the test does not decide. In one variable at : has a minimum, a maximum and neither, and all three have . The monkey saddle has and three directions that go down.
What gradient descent guarantees on a nonconvex function #
Theorem (gradient descent on an -smooth function). Let be -smooth and bounded below by . Gradient descent with step , , satisfies
Proof.
- The descent lemma (lesson 02) needs no convexity: .
- Put . Then , and .
- Sum over . The values of cancel in pairs (the sum telescopes): .
- The smallest of numbers is at most their mean.
What it says and what it does not say.
- It is about the gradient, at the best iterate so far. It says nothing about , and nothing about whether the point is a minimum or a saddle.
- for means iterations to reach .
- The loss decreases at every step (step 2), so GD can never climb out of a basin.
The theorem gives . Which statement does it support?
The bound is about the gradient norm, and only about the best iterate (the minimum over ). A small gradient can be at a saddle, so the theorem cannot promise a minimum. On a nonconvex function there is no bound on in general.
Why strict saddles rarely trap gradient descent #
Linear picture. Near a stationary point with Hessian , . So the error follows . In the eigenbasis of , the component along is multiplied by at every step.
- For (and ): , the component shrinks.
- For : , the component grows.
Only starts with exactly zero component along every direction with converge to the saddle. In the linear picture, this is a subspace of lower dimension; for the real it is a curved set of lower dimension, the stable manifold. A random start lands on it with probability zero.
Escape time. A start at distance from the stable manifold, along the direction with , reaches distance after about
For , , and : steps.
What has been proved.
- Lee, Simchowitz, Jordan and Recht (2016). Let be twice continuously differentiable with an -Lipschitz gradient, and let . Then the set of starting points from which GD converges to a strict saddle has measure zero. So from a random start, if GD converges and every saddle of is strict, the limit is a local minimum. The idea: the GD map has the invertible Jacobian , and at a strict saddle it has an eigenvalue ; the stable manifold theorem does the rest.
- The escape can be slow. Du et al. (2017) built functions where GD needs exponential time to pass a sequence of saddles. Plateaus near saddles can slow training even when they do not stop it.
- Noise helps. Jin, Ge, Netrapalli, Kakade and Jordan (2017): perturbed GD, which adds a small random kick when the gradient is small, reaches an approximate second-order stationary point ( and , for a -Lipschitz Hessian) in iterations, with only a polylogarithmic factor in the dimension. The noise of SGD plays a similar role.
- In high dimensions, saddles are the typical obstacle. Dauphin et al. (2014) argued, with theory from random functions and experiments on networks, that most stationary points with a high loss are saddles, not bad local minima, and that they are often surrounded by plateaus.
Newton's method is attracted to saddles. Newton's method (lesson 10) solves ; it does not look at the sign of the curvature. On the quadratic model, : one step goes exactly to the stationary point, whether it is a minimum or a saddle. Saddle-free Newton (Dauphin et al.) uses instead: along a direction with it moves away from the saddle.
Why the escape time depends on log(1/δ)
In the linear picture, the component along after steps is . Set it equal to and take logarithms: . So the number of steps grows like . A start times closer to the stable manifold costs only extra steps, not times more. With a small (a flat saddle) the factor is large: this is a plateau.
Measuring curvature: Hessian-vector products and power iteration #
For a model with parameters, the Hessian has entries: it cannot be stored. But most methods only need its product with a vector.
Hessian-vector product (HVP). For a vector ,
that is, the derivative of with respect to at : the rate at which the gradient changes when you move along . Three ways to compute it (calculus 08 has the details):
- reverse-over-reverse (Pearlmutter 1994): , a second backward pass through the gradient computation;
- forward-over-reverse: a forward-mode derivative (JVP) of the gradient function in direction ;
- central differences: , two gradients. The error is from truncation plus from rounding, so the best is about times the scale of (about in float64), with a relative error near . In float32 use automatic differentiation.
The two exact methods cost a small constant times one gradient (often quoted as 2 to 5) and extra memory. No matrix appears.
Power iteration (linear algebra 05) needs only HVPs: start from a random unit vector and repeat
where the estimate is the Rayleigh quotient.
If , the direction error shrinks like , and for a symmetric
the eigenvalue error like . Caution: it finds the eigenvalue of largest absolute value. Near a
saddle with a large negative eigenvalue, that is the negative one. The Lanczos method
(linear algebra 14; scipy.sparse.linalg.eigsh with which="LA") needs
fewer products and can target the largest algebraic eigenvalue.
Press "One HVP" a few times. The blue vector turns toward the eigenvector (yellow dashed line); the orange vector is , the only thing the method computes. The dashed ellipse is the image of the unit circle under . The chart shows the error of next to (dashed). Try close eigenvalues: convergence slows down. Try near a saddle: the iteration finds , not .
Newton-CG uses the same products. The Newton step solves . Conjugate gradients needs one HVP per iteration, so a truncated Newton step also never forms . It must stop when it meets negative curvature (), because CG assumes .
Sharpness and the edge of stability #
Definition. The sharpness of the training loss at parameters is , the largest eigenvalue of the Hessian.
Proposition (stability on a quadratic). Let with . Gradient descent with step converges from every start if and only if .
Proof. The error follows exactly. Along the eigenvector the component is multiplied by . All components shrink if and only if for every , that is . Since all , this is . If , the component along grows by per step, with a sign flip at each step: the iterate jumps from side to side with growing size.
The same argument, applied to the linear picture at a minimum of a nonquadratic loss, says: gradient descent can stay at a minimum only if its sharpness is at most . If , the minimum is unstable: tiny errors along grow. So the step size decides which minima GD can converge to. (The worked example in section 4 shows this on a function with a whole curve of minima.)
What real training does (Cohen et al. 2021). Cohen, Kaur, Li, Kolter and Talwalkar trained many networks with full-batch GD and measured the sharpness. They observed, across architectures and tasks:
- Progressive sharpening: while , the sharpness tends to rise during training.
- Edge of stability: once reaches , it stops rising and hovers at or just above .
- The loss goes up and down over short times, but keeps decreasing over long times.
The classical theory of lesson 02 needs for a monotone decrease. Here the local curvature sits at the limit and training still makes progress. The step size does not need to adapt to the curvature: the curvature adapts to the step size.
Compare three step sizes. A small network (97 parameters) is trained with full-batch GD on 20 points, from the same start. The bottom chart shows the sharpness and the line . With the sharpness rises (progressive sharpening) and stays below the line. With or it rises to and stays there, while the loss (top) has small up-and-down steps but keeps decreasing.
Adam at the edge of stability. For Adam, the relevant quantity is the preconditioned sharpness , where is Adam's diagonal preconditioner. Cohen et al. (2022) observed that it rises to and hovers near for , the stability limit of momentum, . With minibatch SGD the sharpness does not settle at one value, but larger steps and smaller batches still lead to flatter regions (Cohen et al. 2021, section 6).
Why the sharpness stops at 2/η: self-stabilization (informal)
Damian, Nichani and Lee (2023) gave a mechanism. When rises above , the iterate starts to oscillate along the top eigenvector with growing size. The loss is not exactly quadratic, and its third derivative couples this oscillation to the gradient of : the oscillation pushes in a direction that lowers the sharpness. When is back below , the oscillation shrinks again. The net effect is that GD follows, approximately, the path of a constrained method that keeps . This explains the hovering in the figure and the short up-and-down steps of the loss.
Full-batch GD with . At the start the sharpness is 50. What is the typical behaviour of the sharpness, according to the edge-of-stability observations?
Progressive sharpening makes rise while . When it reaches , it stops there (the edge of stability). The loss then oscillates over short times but keeps decreasing, so the run does not diverge.
Sharp and flat minima #
A minimum is sharp if the loss rises fast around it (large Hessian eigenvalues) and flat if it rises slowly. An old idea is that flat minima generalize better: a flat minimum is less sensitive to the small differences between the training and the test data. The evidence is mixed, and how you measure sharpness matters.
- Keskar et al. (2017). Large-batch training tends to find sharper minimizers that generalize worse; small-batch training, with more gradient noise, finds flatter ones. (They measured sharpness as the largest loss increase in a small box around the minimum.)
- Dinh et al. (2017): sharpness depends on the parametrization. For a ReLU network, for . So the change does not change the function , but it changes the Hessian and can make a minimum arbitrarily sharp. The same function, so the same test error, with any sharpness you like. Sharpness alone cannot explain generalization.
- Li et al. (2018): filter normalization. Plots of the loss along random directions have the same scale problem. They rescale each filter of the random direction to the norm of the matching filter of the weights. With this normalization, flatter-looking minima went with better test error in their experiments, and skip connections gave smoother landscapes.
- Later studies found both positive and negative results. Large studies of generalization measures (Jiang et al. 2020) ranked some sharpness-based measures among the better ones, while Andriushchenko et al. (2023) found weak or even negative correlation for modern architectures and training setups. Treat "flat means better" as a useful heuristic, not a law.
Sharpness-aware minimization (SAM; Foret et al. 2021). SAM minimizes the worst loss in a ball of radius around the weights:
At a minimum with Hessian , the second-order Taylor expansion gives : the SAM objective adds a penalty proportional to the sharpness.
The SAM update, step by step.
- Linearize the inner problem: with .
- Maximize the linear term over the ball: (Cauchy–Schwarz), with equality for . This is a step of length uphill.
- Take the gradient at the perturbed point, , ignoring how depends on .
- Update with any optimizer, for example .
Each step costs two forward-backward passes. A typical radius in image classification is .
Change the radius . The loss (grey) has a deeper sharp minimum on the left and a flat one on the right. The dashed violet curve is the exact SAM objective: the worst loss in the yellow ball around each point. For it is the loss. As grows, the narrow well is filled first, and the table shows that the SAM objective becomes lower at the flat minimum. Drag the point : the arrows below the axis compare the GD step and the SAM step, which uses the gradient at the ascent point .
For a two-layer ReLU network you replace by . What changes?
, so for every input: the same function. But the second derivatives with respect to the weights change, so the sharpness changes. This is Dinh et al.'s argument that sharpness alone cannot explain generalization.
Answers to section 1. (1) Typically it rises (progressive sharpening) to about and then hovers there (the edge of stability), while the loss goes up and down over short times but decreases over long times. (2) GD does not reach the saddle: grows, and after 145 steps. (3) Yes: power iteration or Lanczos on Hessian-vector products. One iteration is one HVP, a small constant times the cost of one gradient, with memory. Tens of iterations are usually enough for the top eigenvalue.
4. Worked example #
(a) A nonconvex function in two variables. . Then and . The Hessian norm is at most 1, so ; and , so .
- Stationary points: and , so for integers .
- At : , : one negative and one positive eigenvalue, so strict saddles, with .
- At : , : strict local minima, with .
(b) The guarantee and the real run. GD with step from , where .
- The theorem: . For : .
- The run: and . So goes , and halves at each step. Among the first 8 iterates the smallest squared gradient norm is .
The bound is true but loose: it must hold for every -smooth function, including bad ones.
(c) Near the saddle. From exactly, stays 0 (since ), and GD converges to the saddle : this start is on the stable manifold. From : near the saddle , the factor . So first exceeds 1 at step 27 (), and is within of at step 31.
(d) Power iteration and the stability limit. with (eigenvalues 4 and 2), so . From :
- , , and (here ).
- Next and ; then , , .
- The errors shrink by per step.
The sharpness is 4, so GD needs . With the factors are and : convergence. With the first factor is : from , after 50 steps , along the top eigenvector .
(e) The step size selects the minimum. is the smallest "two-layer linear network": the model is the product . Its minimizers form the hyperbola .
- The gradient is . On the hyperbola, , so the Hessian is . Its trace is and its determinant is , so the eigenvalues are 0 (along the hyperbola) and .
- So the minimum has sharpness 2, and has sharpness : the same function , 50 times sharper. This is Dinh et al.'s rescaling with two parameters.
Run GD from , where :
- (): the loss decreases at every step, and GD stops at a nearby minimum with sharpness .
- (): the nearby minima have sharpness above 8, so GD cannot stay there. The loss rises for four steps (), jumps between about and , and GD settles at the flatter minimum , with sharpness .
GD can only stay where the sharpness is at most . This is the rule behind the edge of stability.
5. In code #
NumPy checks the numbers of section 4. The notebook has these cells and the exercises.
import numpy as np
# (a) classify the stationary points of f(x, y) = cos x + y^2/4 by the Hessian
hess = lambda x, y: np.array([[-np.cos(x), 0.0], [0.0, 0.5]])
for x in (0.0, np.pi):
print(round(x, 4), np.linalg.eigvalsh(hess(x, 0.0)))
# 0.0 [-1. 0.5] -> strict saddle
# 3.1416 [0.5 1. ] -> strict local minimum
# (b) escape from the saddle of f = (x^2 - y^2)/2: steps until |y| >= 1
eta, y, k = 0.1, 1e-6, 0
while abs(y) < 1:
y, k = (1 + eta) * y, k + 1
print(k, round(np.log(1e6) / np.log(1 + eta), 2)) # 145 144.95
# (c) the nonconvex GD bound on f = cos x + y^2/4 (L = 1, f_inf = -1), step 1/L = 1
p = np.array([0.5, 1.0])
grad = lambda p: np.array([-np.sin(p[0]), p[1] / 2])
f0, sq = np.cos(0.5) + 0.25, []
for _ in range(8):
sq.append(grad(p) @ grad(p))
p = p - grad(p)
print(f"min |grad|^2 = {min(sq):.1e}, bound 2L(f0 - f_inf)/k = {2 * (f0 + 1) / 8:.2f}")
# min |grad|^2 = 1.5e-05, bound 2L(f0 - f_inf)/k = 0.53
# (d) sharpness of Rosenbrock at its minimizer: power iteration on finite-difference HVPs
def rosen_grad(z):
x, y = z
return np.array([-2 * (1 - x) - 400 * x * (y - x**2), 200 * (y - x**2)])
def hvp(z, v, h=1e-5):
return (rosen_grad(z + h * v) - rosen_grad(z - h * v)) / (2 * h)
z, v = np.array([1.0, 1.0]), np.array([1.0, 0.0])
for _ in range(5):
w = hvp(z, v)
lam, v = v @ w, w / np.linalg.norm(w)
print(round(lam, 3), np.linalg.eigvalsh([[802.0, -400.0], [-400.0, 200.0]]).round(3).tolist())
# 1001.601 [0.399, 1001.601]
# (e) the step size selects the minimum: GD on f(u, v) = (uv - 1)^2 / 2 from (3, 0.1)
for lr in (0.05, 0.25):
u, w = 3.0, 0.1
for _ in range(2000):
r = u * w - 1
u, w = u - lr * r * w, w - lr * r * u
print(f"lr {lr}: uv = {u * w:.6f}, sharpness u^2 + v^2 = {u * u + w * w:.2f}, 2/lr = {2 / lr:.0f}")
# lr 0.05: uv = 1.000000, sharpness u^2 + v^2 = 9.19, 2/lr = 40
# lr 0.25: uv = 1.000000, sharpness u^2 + v^2 = 6.08, 2/lr = 8
In PyTorch, an exact HVP is torch.func.jvp(torch.func.grad(loss_fn), (params,), (v,))[1] (forward-over-reverse), and
scipy.sparse.linalg.eigsh on a LinearOperator built from it gives the top eigenvalue with Lanczos.
6. Where it shows up #
- Training large models. When a run becomes unstable, people estimate the sharpness on a fixed batch with Lanczos on HVPs and compare it with (for Adam: the preconditioned sharpness with ). Gilmer et al. (2022) linked training instabilities to the sharpness exceeding this limit, and found that good choices, such as the learning-rate warmup of lesson 07, help training avoid or leave regions of high curvature.
- Optimizer design. SAM and its variants are used in image classification; for example, SAM let vision transformers train well on ImageNet without large-scale pretraining (Chen, Hsieh and Gong 2022). Loss-landscape plots with filter normalization are a common diagnostic.
- ML for science: saddle points as the goal. In chemistry and materials science, a reaction goes from one minimum of the potential energy surface to another through a transition state, an index-1 saddle point (exactly one negative Hessian eigenvalue). Methods such as the nudged elastic band and the dimer method search for these saddles on purpose. The dimer method finds the lowest-curvature direction from gradients only, in the same spirit as a finite-difference HVP. Machine-learned interatomic potentials make these searches much cheaper.
- Physics-informed neural networks. Their loss landscapes are often badly conditioned because of the differential operators in the loss. Rathore et al. (2024) studied this with Hessian spectra and recommended Adam followed by L-BFGS or a Newton-type method.
7. Common mistakes #
- "GD converged, so it found a minimum." The theorem gives a small gradient. The Hessian decides what the point is.
- "Saddles trap gradient descent." Strict saddles attract only a measure-zero set of starts. The real cost is the time spent near them (plateaus), which grows with and .
- Using Newton's method on a nonconvex loss without changes. It is attracted to saddles. Use damping, a trust region, or a positive semidefinite model (Gauss–Newton, lesson 10).
- Power iteration near a saddle. It returns the eigenvalue of largest absolute value, possibly a large negative one.
Use Lanczos with
which="LA", or shift . - Building the Hessian to get its top eigenvalue. For a big model, use HVPs; never form the matrix.
- The wrong finite-difference step. suits a one-sided difference; a central difference needs about times the scale.
- Calling a short rise of the loss a divergence. At the edge of stability the loss goes up and down but decreases over long times. A real divergence keeps growing.
- Comparing sharpness across parametrizations or across models of different scale, or reading it from loss plots without filter normalization.
8. Check yourself #
- Find and classify the stationary points of . Can GD from a random start converge to the
saddle? Where else can it go?
Answer
gives , and . At : , a strict local minimum with . At : , a strict saddle with . GD with a small step reaches the saddle only from a measure-zero set of starts. But is unbounded below: for the partial derivative pushes to . The theorem of Lee et al. only says "if GD converges, the limit is a minimizer". - Full-batch GD with has measured sharpness 104, and the loss went up in the last three steps. Is the run
diverging?
Answer
Not necessarily. , and at the edge of stability the sharpness hovers at or just above while the loss goes up and down over short times but decreases over long times. Look at the long-time trend; a real divergence keeps growing. - For , at which of the minima and can GD with stay? Which
one generalizes better?
Answer
The sharpness is 2 at and at . GD needs it at most , so it can stay only at . Both compute the same function , so they generalize equally well: sharpness alone does not decide generalization. - A Hessian has eigenvalues and . What does power iteration return, and how do you get
instead?
Answer
It returns , the eigenvalue of largest absolute value. Use Lanczos with `which="LA"`, or run power iteration on with a shift (for example : the eigenvalues become 7 and 2, power iteration finds 7, and ). - You estimate the top Hessian eigenvalue of a -parameter model with 30 Lanczos iterations. Roughly what does it
cost, compared with one training step?
Answer
Each iteration is one HVP, a small constant (about 2 to 5) times the cost of one gradient. So about 60 to 150 gradient computations on the chosen batch, plus memory per stored vector. That is the cost of tens to a hundred training steps, and no matrix. - At a minimum with and Hessian eigenvalues 40 and 1, estimate the SAM objective for
.
Answer
. The worst point in the ball lies along the sharpest direction.
What is a strict saddle?
A stationary point () where the Hessian has a negative eigenvalue, .
What does GD with step guarantee on an -smooth nonconvex ?
: a small gradient at some iterate, not a minimum.
Why do strict saddles rarely trap gradient descent?
Along a direction with , the error grows by per step. Only starts on the stable manifold (measure zero) converge to the saddle.
How many GD steps to escape a saddle from distance ?
About to reach distance ; it grows only like .
Why is Newton's method attracted to saddles?
It solves without looking at the curvature sign: on the quadratic model one Newton step lands exactly on the stationary point.
Write the Hessian-vector product as a derivative, and give its cost.
; by autodiff it costs a small constant (about 2–5) times one gradient, with memory.
When is GD on a quadratic stable, in terms of the sharpness?
If and only if .
What are the edge-of-stability observations (Cohen et al. 2021)?
Sharpness rises during training (progressive sharpening), then hovers near , while the loss is non-monotone over short times but keeps decreasing.
What is Dinh et al.'s objection to "flat minima generalize better"?
For ReLU networks, keeps the function but changes the sharpness, even arbitrarily: sharpness depends on the parametrization.
Write the SAM objective and its ascent step.
; , then step with .
9. Interview angle #
- "Do saddle points trap SGD?" — Not in general. GD from a random start reaches a strict saddle with probability zero (Lee et al.), and noise escapes in polynomial time (Jin et al.). Saddles and the plateaus near them can still slow training.
- "What does gradient descent guarantee on a nonconvex loss?" — With step , the best squared gradient norm is at most : a first-order stationary point, iterations; prove it with the descent lemma and a telescoping sum.
- "How do you get the top Hessian eigenvalue of a 1B-parameter model?" — Lanczos or power iteration on HVPs from autodiff, on a fixed batch; a few gradients per iteration, tens of iterations.
- "What is the edge of stability?" — Full-batch GD drives the sharpness up to and trains there with a non-monotone but decreasing loss; the step size selects how sharp a region GD can stay in.
- "Do flat minima generalize better?" — Often correlated, with the right normalization (Li et al.), but sharpness changes under reparametrization (Dinh et al.). SAM optimizes for flatness at twice the cost per step.
10. Practice #
The notebook for this lesson runs in Colab. It has five exercises, each with a check cell and a folded solution:
- Measure the escape time of GD from a saddle and compare it with .
- Write a central-difference HVP and test it on a quadratic and on a small NumPy network.
- Write power iteration on HVPs and compare its result with
np.linalg.eigvalshof the full Hessian. - Train the small network with full-batch GD for two step sizes and track the sharpness against .
- Write one SAM step and compare the SAM objective at a sharp and a flat minimum.
11. Watch and read #
- Cohen et al., Gradient Descent on Neural Networks Typically Occurs at the Edge of Stability (ICLR 2021).
- Cohen et al., Adaptive Gradient Methods at the Edge of Stability (2022).
- Damian, Nichani and Lee, Self-Stabilization: The Implicit Bias of Gradient Descent at the Edge of Stability (ICLR 2023).
- Lee, Simchowitz, Jordan and Recht, Gradient Descent Converges to Minimizers (COLT 2016).
- Jin et al., How to Escape Saddle Points Efficiently (ICML 2017).
- Dauphin et al., Identifying and attacking the saddle point problem in high-dimensional non-convex optimization (NeurIPS 2014).
- Keskar et al., On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima (ICLR 2017).
- Dinh et al., Sharp Minima Can Generalize For Deep Nets (ICML 2017).
- Li et al., Visualizing the Loss Landscape of Neural Nets (NeurIPS 2018).
- Foret et al., Sharpness-Aware Minimization for Efficiently Improving Generalization (ICLR 2021).
- Andriushchenko et al., A Modern Look at the Relationship between Sharpness and Generalization (ICML 2023).
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.