HomeAI & Machine LearningSharp vs. Flat Minima: Why Flatness Predicts Generalization

Sharp vs. Flat Minima: Why Flatness Predicts Generalization

Interactive 3D loss landscape with a sharp narrow minimum and a flat wide minimum: watch SGD noise and Sharpness-Aware Minimization (SAM) decide which basin an optimizer settles in, and see why the flat one survives the train-to-test distribution shift.

AI & Machine Learning2DAdvanced60 FPS📱 Mobile-adapted
gradient-descent-loss-landscape ↗ Open standalone

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.

⚙ Under the hood

Interactive 3D loss landscape with a sharp narrow minimum and a flat wide minimum: watch SGD gradient noise and real Sharpness-Aware Minimization (SAM) decide which basin an optimizer settles in, then reveal the generalization gap by switching to the shifted test-loss surface.

gradient descentloss landscapegeneralizationSAM optimizerSGD noiseflat minima

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)