Deep neural network calibration by reducing classifier shift with stochastic masking

Jiani Ni, He Zhao, Yibo Yang, Dandan Guo

TL;DR

This paper introduces MaC-Cal, a novel method to improve the reliability of confidence scores from deep neural networks (DNNs) by reducing "classifier shift." MaC-Cal uses a two-stage training process involving stochastic masking and adaptive sparsity to ensure that a model's confidence in its predictions aligns better with its actual accuracy, addressing both over- and underconfidence.

What Problem Does This Paper Address?

Deep neural networks (DNNs) are powerful but often suffer from poor calibration, meaning their predicted confidence scores don't accurately reflect the probability of being correct. This is particularly problematic in safety-critical applications like autonomous driving and healthcare, where incorrect confidence can lead to serious consequences. While many methods focus on improving calibration, they often overlook issues caused by underconfidence or are limited in their applicability. This paper addresses the problem of unreliable confidence estimates in DNNs by proposing a method that specifically targets and reduces "classifier shift," a phenomenon they identify as a primary cause of calibration errors, leading to more robust and trustworthy predictions.

Methods

MaC-Cal employs a two-stage training strategy:

  • Stage 1: Joint Training: The feature extractor and the classifier are trained together using a standard supervised loss function (e.g., cross-entropy or focal loss). Data augmentation techniques like Mixup can also be used here to enhance generalization.
  • Stage 2: Masked Retraining with Adaptive Sparsity:
    • The feature extractor is frozen, and the classifier is retrained.
  • Stochastic Masking: Random binary masks are applied to the classifier's weights during training. This introduces sparsity, making the model more robust to perturbations and reducing overconfidence.
  • Classifier Restructure: The original linear classifier is replaced with a lightweight two-layer bottleneck structure to enhance its representational capacity and stability under sparse perturbations.
  • Adaptive Sparsity: Instead of using a fixed sparsity level, MaC-Cal dynamically adjusts the mask retention probability (sparsity parameter q) based on the model's observed accuracy and average confidence on the training set. This adaptive mechanism aims to prevent under- or over-regularization and reduces the need for manual hyperparameter tuning. The sparsity parameter q is updated using a feedback loop that considers the difference between confidence and accuracy.

Datasets

The paper evaluates MaC-Cal on the following datasets:

  • CIFAR-10
  • CIFAR-100
  • Tiny-ImageNet
  • SVHN (used as an Out-of-Distribution (OOD) dataset)
  • CIFAR-10-C and CIFAR-100-C (corrupted versions of CIFAR datasets to simulate real-world distributional changes and test robustness)

Key Insights and Ideas

  • Classifier Shift as a Root Cause: The paper identifies "classifier shift" as a primary driver of calibration errors, both overconfidence and underconfidence. This insight shifts focus from general model improvements to specifically targeting the classifier's role.
  • Stochastic Masking for Robustness: Applying random masks to classifier weights during training acts as a form of regularization, making the model less sensitive to specific parameter configurations and improving calibration.
  • Adaptive Sparsity for Dynamic Regularization: The adaptive sparsity mechanism is crucial for avoiding the pitfalls of fixed sparsity. It allows the model to adjust its regularization strength dynamically based on its learning progress, leading to more stable and effective calibration.
  • Two-Stage Approach for Decoupling: Separating feature learning from classifier adaptation allows the model to first learn robust representations and then refine the classifier for better confidence estimation without compromising accuracy.
  • Addressing Both Over- and Underconfidence: Unlike many methods that primarily focus on overconfidence, MaC-Cal is designed to mitigate both over- and underconfidence, offering a more comprehensive calibration solution.

Key Results

  • Superior Calibration: MaC-Cal consistently achieves the lowest Expected Calibration Error (ECE) across various models and datasets, often showing over 90% relative reduction compared to the baseline. For instance, on CIFAR-100 with ResNet-110, ECE was reduced from 17.85 to 1.44.
  • Competitive Accuracy: The method maintains competitive classification accuracy, with minimal drops even when combined with other techniques.
  • Robustness: MaC-Cal demonstrates strong robustness against various corruptions and distribution shifts (tested on CIFAR-10/100-C datasets), maintaining relatively low ECE values where other methods struggle.
  • Efficiency: MaC-Cal shows competitive or superior training times compared to other calibration methods, offering an efficient trade-off between performance and computational cost.
  • Generalization: The method shows strong generalization capabilities on OOD data.

Limitations and Future Work

  • Hyperparameter Sensitivity (Mitigated): While the adaptive sparsity mechanism aims to reduce sensitivity to hyperparameters, the paper still mentions a hyperparameter y for the adaptive sparsity update. Figure 7 shows that the method is robust across a wide range of y, indicating low sensitivity.
  • Training Data Dependence: The adaptive sparsity mechanism relies on training set metrics (accuracy and confidence). The paper acknowledges that training accuracy can overestimate generalization, and y is used to down-weight this effect.
  • Future Work: The paper suggests that MaC-Cal's components form a synergistic framework and that its integration significantly improves calibration. Future work could explore further synergistic combinations and applications of these components. The adaptive sparsity mechanism is highlighted as a scalable solution for diverse training conditions, implying potential for broader applicability.

Summary updated

BibTeX
@article{ni2026deep,
  author = {Jiani Ni and He Zhao and Yibo Yang and Dandan Guo},
  title = {{Deep neural network calibration by reducing classifier shift with stochastic masking}},
  journal = {Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=fD86yWogIP},
}
Figure