Class Adaptive Network Calibration

Bingyuan Liu, Jérôme Rony, Adrian Galdran, Jose Dolz, Ismail Ben Ayed

TL;DR

Deep neural networks are notoriously overconfident, and existing calibration methods apply a single, fixed penalty weight across all classes. This paper introduces Class Adaptive Label Smoothing (CALS), an Augmented Lagrangian Multiplier framework that dynamically learns class-specific calibration weights during training. It slashes calibration error by massive margins—especially in imbalanced and long-tailed settings—without sacrificing predictive accuracy.

What Problem Does This Paper Address?

Standard cross-entropy loss encourages deep neural networks to produce overconfident predictions by endlessly driving softmax probabilities toward 1.0, even after classification error hits zero. In safety-critical domains like autonomous driving or medical imaging, miscalibrated probability estimates can be disastrous.

Recent training-time remedies—such as Focal Loss, Label Smoothing, and Margin-based Label Smoothing (MbLS)—penalize excessive confidence via an extra loss term. However, they suffer from two major flaws:

  1. Uniform penalties: They use a single global scalar weight across all classes, ignoring the fact that head, tail, easy, and difficult classes have wildly different regularization needs.
  2. Static weighting: Penalty weights are fixed prior to training, requiring expensive hyperparameter sweeps and preventing the model from dynamically adapting as training progresses.

Methods

The authors propose Class Adaptive Label Smoothing (CALS), casting network calibration as a constrained optimization problem solved via a tailored Augmented Lagrangian Multiplier (ALM) algorithm (CALS-ALM):

  • Class-Wise Margin Formulation: Building on MbLS, CALS enforces that the gap between the top logit and other logits stays below a margin $m$. Instead of assigning an intractable per-sample multiplier or a blunt single global multiplier, CALS introduces distinct multipliers $\lambda_k$ for each class $k \in \{1, \dots, K\}$.
  • ALM Tailored for Deep Learning: Standard ALM cannot be directly applied to deep networks due to stochastic mini-batch training, data augmentation, batch normalization, and dropout. To adapt it:
  • Relaxed Inner Optimization: The inner loop runs for a standard training epoch rather than solving to full convergence.
  • Validation-Based Dual Updates: Lagrange multipliers $\lambda$ and penalty parameters $\rho$ are updated at the end of each epoch using the validation set rather than the training set, preventing the dual parameters from overfitting.
  • PHR Penalty Function: CALS uses the smooth Powell-Hestenes-Rockafellar (PHR) penalty function, normalizing constraints by margin $m$ and averaging over classes for numerical stability.
  • CALS-HR: A simpler, rule-based heuristic alternative that adjusts class multipliers based on whether constraint violations increase or decrease.
       Training Set (D_train)                 Validation Set (D_val)
┌──────────────────────────────────┐   ┌──────────────────────────────────┐
│   Standard Forward/Backward      │   │  Evaluate logit constraints      │
│   Update model parameters θ      │──>│  Update multipliers λ_k and ρ_k  │
│   via mini-batch SGD             │<──│  using PHR derivative            │
└──────────────────────────────────┘   └──────────────────────────────────┘

Datasets

The authors evaluated CALS across diverse computer vision and NLP benchmarks (no new datasets were introduced):

  • Standard Image Classification: Tiny-ImageNet (64×64 images, 200 classes) and ImageNet (1,000 classes, 1.2M+ images).
  • Long-Tailed Image Classification: ImageNet-LT (1,000 classes with severe class imbalance ranging from 5 to 1,280 samples per class).
  • Semantic Segmentation: PASCAL VOC 2012 (dense per-pixel classification across 21 classes).
  • Text Classification: 20 Newsgroups (20 topic categories).

Key Insights and Ideas

  • Sample-wise multipliers don’t scale; class-wise does: While an ideal Lagrangian would assign a multiplier to every single sample and class, storing sample-wise multipliers for dense tasks like segmentation would demand massive memory (e.g., ~445 GiB on Cityscapes). Class-wise multipliers require storing only $K$ scalars, scaling smoothly to pixel-level tasks.
  • Dual updates on validation prevent overfitting: Optimizing Lagrange multipliers directly on training data causes the network to overfit the calibration penalty. Estimating the multipliers on validation data acts as an automated regularization controller.
  • Dynamic tracking of miscalibration: Multiplier trajectories reveal that CALS automatically ramps up penalties early in training when the model aggressively pushes accuracy, and scales penalties down once logits are safely calibrated within the target margin.

Key Results

CALS-ALM consistently achieves state-of-the-art calibration measured by Expected Calibration Error (ECE), while matching or exceeding baseline classification accuracy:

  • ImageNet-LT (Long-Tailed): On ResNet-50, CALS-ALM reduces ECE from 28.12% (Cross-Entropy) and 6.16% (MbLS) down to 2.15%, while maintaining superior accuracy (38.56%). On SwinV2-T, ECE drops from 31.82% to 2.32%.
  • Standard ImageNet: CALS-ALM achieves 1.46% ECE (ResNet-50) and 1.61% ECE (SwinV2-T), outperforming Focal Loss (1.60% ECE, but with a ~2.5% drop in accuracy) and MbLS (4.44% ECE).
  • Semantic Segmentation (PASCAL VOC 2012): DeepLabV3 achieves 4.66% ECE with CALS-ALM (compared to 14.75% for CE and 5.22% for MbLS) with a competitive 66.77% mIoU.
  • Text Classification (20 Newsgroups): ECE falls from 22.75% (CE) to 2.04% (CALS-ALM), alongside top accuracy (68.32%).

Limitations and Future Work

  • Validation Distribution Dependency: The algorithm assumes the validation set is independent and identically distributed ($i.i.d.$) relative to the training set. The impact of updating multipliers on out-of-distribution or corrupted validation data remains open.
  • Hyperparameter Sensitivity: Although CALS eliminates the search for class weights, practitioners must still select the margin hyperparameter $m$ (typically $m \approx 10$ for vision tasks).

Summary updated

BibTeX
@inproceedings{liu2024class,
  author = {Bingyuan Liu and Jérôme Rony and Adrian Galdran and Jose Dolz and Ismail Ben Ayed},
  title = {{Class Adaptive Network Calibration}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  url = {https://openreview.net/forum?id=uFwdFpeIsy},
}
Figure