Plots 1D and 2D slices of neural-network loss surfaces and introduces filter normalization so that slices of different networks can be compared (NeurIPS 2018).
Loss Landscapes, Sharpness & Flat Minima
What 2D slices of a loss surface show and hide, how Hessian curvature measures sharpness, why the link between flat minima and generalization is contested, and how SAM trains toward flat regions.
Intuition
The idea in plain words, before the symbols.
Training moves the parameters downhill on the loss. For a neural network that surface has one dimension per parameter: millions or billions of them.
A picture of a loss landscape is therefore a slice: the loss along one or two chosen directions through parameter space, with everything else held fixed (Li et al., 2018). Slices are useful, but what they show depends on which directions are chosen and how they are scaled.
Two terms come up often:
- Sharp minimum: a small change to the weights raises the loss a lot. The curvature, measured by the largest eigenvalues of the Hessian, is high.
- Flat minimum: the loss stays low over a wide region around the minimum.
The idea that flat minima generalize better goes back to Hochreiter and Schmidhuber (1997), and Keskar et al. (2017) found that large-batch training tends to converge to sharper minima that generalize worse. The idea is contested. Dinh et al. (2017) showed that rescaling the weights of a ReLU network can make a minimum arbitrarily sharp without changing the function the network computes, so sharpness measured this way cannot by itself explain generalization.
Sharpness-aware minimization (SAM; Foret et al., 2021) builds a preference for flat regions into training: it minimizes the highest loss within a small ball around the current weights, not just the loss at one point.
Study prompts for this section: Intuition
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Mathematics
Definitions, assumptions and the derivation.
Let be the training loss for parameters . Near a point , a quadratic approximation is:
where is the Hessian (curvature).
A common proxy for "sharpness" is how much loss can increase under a small perturbation. SAM turns that local-neighborhood idea into an objective:
Here is the largest increase in loss within distance . At a minimum, where and has no negative eigenvalues, the quadratic approximation gives : sharpness is the largest Hessian eigenvalue, scaled by the radius.
SAM minimizes the worst-case training loss in the -ball. In practice it approximates the inner maximization with one normalized gradient step, above, and then updates the weights with the gradient taken at the perturbed point: .
The same limits gradient descent: on a quadratic, a fixed step converges only if (see Gradient Descent). Cohen et al. (2021) found that full-batch gradient descent on neural networks pushes up until it hovers just above , while the loss keeps falling over the long run. The code below checks the quadratic bound.
Study prompts for this section: Mathematics
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Code
The same calculation as runnable code, in the notation of the derivation.
import numpy as np
# Anisotropic quadratic: sharp along x (large curvature), flat along y (small curvature).
a, b = 20.0, 1.0 # Hessian eigenvalues
lam_max = max(a, b)
def L(w): return 0.5 * (a * w[0] ** 2 + b * w[1] ** 2)
def grad(w): return np.array([a * w[0], b * w[1]])
print("stable if eta < 2/lambda_max =", round(2.0 / lam_max, 3))
for eta in [0.02, 0.08, 0.12]:
w = np.array([1.0, 1.0])
ok = True
for _ in range(60):
w = w - eta * grad(w)
if not np.isfinite(L(w)) or np.linalg.norm(w) > 1e6:
ok = False; break
print("eta =", eta, "final L =", round(L(w), 6), "status =", "ok" if ok else "diverged")
Study prompts for this section: Code
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Demo
Change an input, predict the result, and see which quantities respond.
Explore Loss Landscapes, Sharpness & Flat Minima
Observation guide
Optional and ungraded. Opening a guide saves nothing.
Choose what to inspect in Loss Landscapes, Sharpness & Flat Minima, then open its guide.
The demo has two parts.
- Part 1: a two-parameter toy loss with a sharp and a flat minimum. Step SGD and SAM from the same start, read the largest Hessian eigenvalue from the heat map, and predict which path ends in the less sharp region.
- Part 2: a toy sharpness trace drawn against the line . Predict whether it stays below the line, hovers near it, or crosses it and diverges.
Both parts use made-up toy surfaces and traces, not measurements from a trained network.
Study prompts for this section: Demo
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Concept: Loss Landscapes, Sharpness & Flat Minima
What is the smallest example of Loss Landscapes, Sharpness & Flat Minima you can work through by hand, and what does it show?
DetailsOptimization
Reference id
concept:optimization/loss-landscapesAfter the first pass
Go deeper
Optional material for a second reading. Sources are always shown; the other panels open from their headings or from these links, and closing one keeps what you wrote or revealed.What to look for in each sectionChoose a section and what you expect to see in it, then read short advice.
Section by section
Choose what to look for in each section
What 2D slices of a loss surface show and hide, how Hessian curvature measures sharpness, why the link between flat minima and generalization is contested, and how SAM trains toward flat regions.

Start with the picture, metaphor, or geometric mechanism.
Choose what you expect to see in this section of Loss Landscapes, Sharpness & Flat Minima.
Questions to ask of the pictureChoose a part of the picture and what you expect, then read short advice.
Looking at the picture
Questions to ask of the picture
What 2D slices of a loss surface show and hide, how Hessian curvature measures sharpness, why the link between flat minima and generalization is contested, and how SAM trains toward flat regions.
Which part of the picture should you look at first?
Pick the part of the picture you expect to explain Loss Landscapes, Sharpness & Flat Minima.
Sources
References for this page
A reference shows where an idea comes from; it does not vouch for every step on this page.Finds that large-batch training tends to converge to sharper minima that generalize worse, measuring sharpness as the loss increase within a small neighborhood (ICLR 2017).
Introduces SAM, which minimizes the worst-case training loss in a small neighborhood of the weights using a one-step approximation of the inner maximization (ICLR 2021).
Early argument that minima where the loss stays low over a large region of weight space generalize better. Neural Computation 9(1), 1-42.
Shows that the parameter symmetries of ReLU networks allow equivalent networks at arbitrarily sharper minima, so common flatness measures cannot by themselves explain generalization (ICML 2017).
Finds that during full-batch gradient descent the largest Hessian eigenvalue rises until it hovers just above 2/η, while the loss decreases over long timescales but not monotonically (ICLR 2021).
What each claim rests on1 claim, each with its sources, where it appears on this page, and its caveats.
Claims and sources
What 2D slices of a loss surface show and hide, how Hessian curvature measures sharpness, why the link between flat minima and generalization is contested, and how SAM trains toward flat regions.
The checks were made by this site, not by an independent reviewer.
Li supports 1D/2D slices and filter-wise normalization caveats. Keskar supports sharp/flat minima as perturbation-sensitivity diagnostics tied to generalization, while using an imperfect epsilon-scale-depend...
Does not cover the edge of stability or the 2/eta code and demo (see Cohen et al.), Hessian spectra of real networks, any guarantee that flat minima generalize, or a sharpness measure unchanged by reparamete...
Li supports low-dimensional 1D/2D slices and filter-normalized comparisons. Keskar supports sharp/flat minima as perturbation-sensitivity diagnostics tied to generalization but with an imperfect epsilon-dependent metric. Foret supports SAM's worst-case neighborhood objective and first-order perturbation approximation. Not checked: the edge of stability, the 2/eta code, part 2 of the demo, real-network Hessian spectra, any guarantee that flat minima generalize, and reparameterization-invariant sharpness.
Explain it without the pageWrite your own explanation before asking for feedback. Your draft and any hints stay while this page is open.
Practice · Loss Landscapes, Sharpness & Flat Minima
Try the idea in your own words
What 2D slices of a loss surface show and hide, how Hessian curvature measures sharpness, why the link between flat minima and generalization is contested, and how SAM trains toward flat regions.
Concept · Selected for practice
Loss Landscapes, Sharpness & Flat Minima
What it rests on: Sources: Visualizing the Loss Landscape of Neural Nets; On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima; Sharpness-A...
Context and links
Optimization
Explain the mechanism
For Loss Landscapes, Sharpness & Flat Minima: What is the smallest example of Loss Landscapes, Sharpness & Flat Minima you can work through by hand, and what does it show? Explain your answer, including what changes, why, and which assumption matters.
A rough first thought is enough. Your draft stays when you change tasks.
Your draft stays on this page and is cleared when you leave or reload.
A little help · Explain
Open one hint at a time. These are suggestions, not your answer or a grade.
0 of 3 hints shown for this question.
Clearing your answer keeps this help record. Outside help is your own report; this page cannot check it.
Where am I stuck? (optional)
Take your draft to a feedback conversation
No AI feedback runs here. You can copy a prompt to use elsewhere; nothing is sent automatically. Review the text before sharing, and leave out private information.
Write an attempt before copying a feedback prompt.
A draft, or an AI reply to it, is not a test of what you have learned. To check that, try a different case later without help.
Ask about this pagePick one item on this page and copy a prompt about it into an AI assistant you already use. Notes you write here stay in this browser.
a, b = 20.0, 1.0 # Hessian eigenvaluesYour question
Choose what your question is about
Pick the idea, equation, source, code, claim, misconception or demo state you want to ask about. The prompt you copy includes it, so the answer can stay on that item.Open the draft below to save one note and next action in this browser.
Loss Landscapes, Sharpness & Flat Minima
What is the smallest example of Loss Landscapes, Sharpness & Flat Minima you can work through by hand, and what does it show?
Fixed prompts generated from this item. They are not comments from people or independent reviews.
The 6 cited sources must support this exact item, not just the surrounding topic.
Connect the definition to one equation, piece of code or demo before widening the discussion.
Change one input, then check that the same relationship holds in the mathematics, the code and the demo.
You can state the mechanism in your own words
Local action draftNo local draft saved yetOpen when you are ready to write one next action
This draft stays in this browser and is attached to this item only.
- What the 6 cited sources say about this exact item
- The definition, its prerequisites, and a contrasting concept
- The equation or code that makes the concept concrete
- One demo state that shows what stays the same as the inputs change
- You can state the mechanism in your own words
- You can name the prerequisite that would clear up the confusion
- You can predict how the result changes when one input changes
Reference id
concept/concept-notebook/optimization/loss-landscapes
concept:optimization/loss-landscapes