Drag to orbit · scroll to zoom · click surface to drop marker
Sharp minimum Flat minimum Optimizer trajectory
⚠ Couldn't load the 3D engineThree.js failed to load from the CDN. Check your connection and reload.

Sharp vs. Flat Minima: Why Flatness Predicts Generalization

Two minima can reach the exact same training loss and still behave completely differently once the model meets new data. This simulator renders a real two-dimensional loss surface carved with a narrow, deep "sharp" minimum and a wide, shallow-walled "flat" minimum, then lets a marker perform genuine stochastic gradient descent across it — with a noise slider that reproduces mini-batch gradient noise and a Sharpness-Aware Minimization (SAM) toggle that runs the real ascent-then-descent SAM update rule. Switching the rendered surface to the test-loss landscape reveals the generalization gap directly: the sharp basin's floor rises sharply under the train/test shift while the flat basin barely moves, which is exactly why flat minima are prized in modern deep learning.