NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Towards Understanding The Calibration Benefits of Sharpness-Aware Minimization

Chengli Tan, Yubo Zhou, Haishan Ye, Guang Dai, Junmin Liu, Zengjie Song, Jiangshe Zhang, Zixiang Zhao, Yunda Hao, Yong Xu

TL;DR

Modern deep neural networks are notoriously overconfident, which poses a massive risk in safety-critical applications like autonomous driving and healthcare. This paper reveals that Sharpness-Aware Minimization (SAM)—an optimizer famous for boosting generalization—also naturally calibrates models by implicitly maximizing predictive entropy. Building on this theoretical breakthrough, the authors introduce Calibrated SAM (CSAM), a novel variant that achieves state-of-the-art calibration without sacrificing accuracy.

The Problem: Overconfident Neural Networks

Deep neural networks (DNNs) often suffer from miscalibration. Ideally, if a model is 90% confident in a prediction, it should be correct 90% of the time. However, modern overparameterized networks trained with standard Stochastic Gradient Descent (SGD) and Cross-Entropy loss tend to be wildly overconfident, pushing prediction probabilities close to 100% even when they are wrong.

Comparison of confidence and calibration between SGD and SAM.

While post-hoc fixes (like Temperature Scaling) or training-time penalties (like Focal Loss or Label Smoothing) exist, they often require hold-out validation sets or end up hurting the model's overall accuracy. Recently, Sharpness-Aware Minimization (SAM) has become popular for helping models generalize better by finding "flat" regions in the loss landscape. Empirical observations hinted that SAM also produces better-calibrated models, but why this happens was unknown. This paper formally investigates the mathematical reasons behind SAM's calibration benefits and leverages those insights to build an even better optimizer.

Methods: Theory and Calibrated SAM

The authors take a two-pronged approach: theoretical analysis and algorithmic innovation.

  1. Theoretical Analysis of SAM: Standard SAM works by calculating a "worst-case" perturbation to the model's weights, and then updating the weights to minimize that perturbed loss. The authors mathematically prove that for Cross-Entropy loss, this perturbed loss acts as an implicit maximum-entropy regularizer. Essentially, SAM naturally penalizes the model when it becomes too confident, forcing the predictive distribution to remain softer and more realistic.
  2. Calibrated SAM (CSAM): Realizing that SAM's entropy penalty is strongest during the late stages of training (when the model is highly confident), the authors propose a tweak. CSAM modifies the per-example loss function in SAM's outer optimization loop. If a training example is already highly confident (probability > 0.5), CSAM applies a hyperparameter-controlled penalty to suppress its gradient contribution. This forces the optimizer to focus on less confident examples, further smoothing the model's overall confidence.

Datasets

The authors evaluate their methods across a robust suite of standard and Out-of-Distribution (OOD) datasets:

  • In-Distribution: CIFAR-10, CIFAR-100, Tiny-ImageNet, and the large-scale ImageNet-1K.
  • Out-of-Distribution (Robustness): SVHN, CIFAR-10-C, CIFAR-100-C, and ImageNet-C (datasets corrupted with synthetic noise, blur, and weather effects to test real-world reliability).

Key Insights and Results

  • SAM is a built-in calibrator: You don't necessarily need complex post-hoc calibration pipelines. The authors found that an uncalibrated model trained with SAM is often better calibrated out-of-the-box than an SGD-trained model that has been explicitly fixed using post-hoc Temperature Scaling.
  • Calibration survives distribution shifts: A major problem with post-hoc calibration is that it breaks down when the real-world data looks different from the training data. Because SAM bakes calibration directly into the model weights via entropy regularization, its reliability holds up remarkably well on corrupted OOD datasets.
  • Massive ECE Reductions: Expected Calibration Error (ECE) measures the gap between confidence and accuracy (lower is better). On CIFAR-100 (ResNet-56), the ECE of standard SGD is roughly 6 times higher than that of SAM.
  • ImageNet-1K Performance: On a ResNet-50 trained on ImageNet-1K, standard SGD yields an ECE of 3.39%. SAM drops this to 1.52%. The newly proposed CSAM pushes it even lower to 1.18%, while simultaneously improving test accuracy (from 76.97% to 77.95%).
  • Beating the Baselines: CSAM consistently outperformed a wide array of specialized calibration techniques—including Focal Loss, Mixup, Label Smoothing, and Bayesian Neural Networks—across multiple architectures (ResNets, WideResNets, and Vision Transformers).

Limitations and Future Work

The authors acknowledge that their theoretical analysis and primary algorithmic design are currently limited to the Cross-Entropy (CE) loss function. While CE is the standard for classification, it leaves open the question of how SAM interacts with other loss formulations. However, they do provide preliminary results suggesting that SAM and CSAM can be successfully integrated with other training losses (like Focal Loss or Adaptive Label Smoothing) to achieve even lower calibration errors, marking a highly promising direction for future research.

Summary updated

BibTeX
@inproceedings{tan2026towards,
  author = {Chengli Tan and Yubo Zhou and Haishan Ye and Guang Dai and Junmin Liu and Zengjie Song and Jiangshe Zhang and Zixiang Zhao and Yunda Hao and Yong Xu},
  title = {{Towards Understanding The Calibration Benefits of Sharpness-Aware Minimization}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=c0ERcCz6lD},
}
Figure