SAM (Sharpness-Aware Minimization) is a training procedure that minimizes not only the value of the loss but also the "sharpness" of the loss around the weights. It was presented by Foret et al. at ICLR in 2021.
Modern deep learning models have a very large number of parameters and can drive the training loss close to 0. However, even among minima with similarly low training loss, generalization (performance on test data) can differ greatly. Building on prior work on the relationship between the flatness of the loss landscape and generalization, the paper takes the following view.
- Sharp minima: The loss rises steeply when the weights shift even slightly. Performance is thought to degrade easily under small differences between training and test data.
- Flat minima: The loss stays low for nearby weights as well. Performance is thought to be maintained even when the data changes slightly.
SAM looks for weights at which the loss is low everywhere within a radius . It only requires computing the gradient twice per update and can be used on top of ordinary optimizers such as SGD.
An analogy is choosing a campsite at the bottom of a valley: a wide basin, even if somewhat shallower, is safer than a narrow, deep ravine in case you slip.

