Calibration-Aware Bayesian Learning

Jiayi Huang, Sangwoo Park, Osvaldo Simeone

TL;DR

This paper introduces Calibration-Aware Bayesian Neural Networks (CA-BNNs), a framework that combines the uncertainty-quantification strengths of Bayesian learning with explicit, data-driven calibration penalties. By optimizing a "calibration-aware free energy," the authors produce models that are significantly more reliable—meaning their confidence scores actually match their true accuracy—even when the underlying model assumptions are imperfect.

What Problem Does This Paper Address?

In high-stakes fields like healthcare or autonomous driving, we don't just need a model to be right; we need to know when it might be wrong. This is the essence of calibration: if a model assigns a 90% confidence score to a set of predictions, it should be correct exactly 90% of the time.

Currently, there are two main ways to handle this, but both have flaws:

  1. Frequentist Calibration: Uses data-dependent regularizers (like penalizing the difference between confidence and accuracy) during training. While this helps calibration, it fails to capture "epistemic uncertainty"—the uncertainty that comes from simply not having enough training data.
  2. Bayesian Learning: The "gold standard" for uncertainty. It treats model parameters as random variables and uses an ensemble approach. However, Bayesian models are notoriously sensitive to model misspecification. If your prior beliefs or your model architecture don't perfectly match the real world, the resulting "calibrated" probabilities can be wildly off.

The authors tackle the challenge of creating a model that captures epistemic uncertainty while remaining robustly calibrated under misspecification.

Methods

The core contribution is the CA-BNN framework, which integrates two types of regularization into a single Variational Inference (VI) objective:

  • Data-Independent Regularization (The Bayesian Part): A Kullback-Leibler (KL) divergence term that forces the model's parameter distribution to stay close to a prior distribution.
  • Data-Dependent Regularization (The Calibration Part): A differentiable approximation of the Expected Calibration Error (ECE).

The authors optimize a "calibration-aware free energy" that balances standard training loss, the Bayesian prior, and the calibration penalty.

A Fully Differentiable Upgrade

A secondary but vital contribution is the refinement of the Weighted Maximum Mean Calibration Error (WMMCE). Standard ECE is non-differentiable because it relies on hard "max" operations (picking the winning class). The authors introduce a fully differentiable version by using:

  • Smoothed Maximum Operators: Replacing the hard max with a temperature-controlled softmax-like function.
  • Differentiable Rank Functions: Allowing the "correctness score" to be part of the gradient flow.

Datasets

The researchers evaluated their approach on two standard benchmarks:

  1. 20 Newsgroups: A text classification dataset used to test a convolutional neural network with global pooling.
  2. CIFAR-10: A classic image classification dataset, where they fine-tuned a pre-trained ResNet18 model.

Key Insights and Ideas

  • The Hybrid Advantage: The paper demonstrates that Bayesian ensembling and explicit calibration penalties are complementary, not redundant. The Bayesian part handles data scarcity, while the calibration penalty corrects for the model's inherent biases or incorrect assumptions.
  • Differentiability is Key: The authors show that their "fully differentiable" version of the calibration regularizer outperforms previous versions that ignored the dependence of the classification decision on the model parameters.
  • Robustness to Hyperparameters: While adding a new hyperparameter ($\lambda$ for calibration weight) might seem like a burden, the experiments show that calibration improves steadily as $\lambda$ increases, without significantly hurting the model's overall accuracy.

Key Results

The CA-BNN consistently outperformed standard frequentist (FNN), standard Bayesian (BNN), and frequentist calibration-aware (CA-FNN) models.

  • CIFAR-10 Performance: CA-BNN achieved an ECE of 0.669%, compared to 1.522% for a standard BNN and a much higher 5.722% for a standard frequentist model.
  • 20 Newsgroups: CA-BNN reduced the ECE by more than 2% compared to its frequentist counterpart (CA-FNN).
  • Reliability Diagrams: Visualizations showed that CA-BNN's confidence-to-accuracy curve followed the ideal 45-degree diagonal much more closely than any other method, effectively eliminating the "overconfidence gap" common in deep learning.

Limitations and Future Work

  • Computational Overhead: Bayesian methods, especially those involving ensembling and complex regularizers, are more computationally expensive than standard training.
  • Distributional Shift: The authors acknowledge that while CA-BNN works well on standard test sets, its performance under "distributional shift" (when the test data looks different from the training data) remains an open question for future research.
  • Security: The authors suggest investigating whether these well-calibrated models are more or less robust to membership inference attacks (where an attacker tries to determine if a specific data point was in the training set).

Summary updated

Abstract

Deep learning models, including modern systems like large language models, are well known to offer unreliable estimates of the uncertainty of their decisions. In order to improve the quality of the confidence levels, also known as calibration, of a model, common approaches entail the addition of either data-dependent or data-independent regularization terms to the training loss. Data-dependent regularizers have been recently introduced in the context of conventional frequentist learning to penalize deviations between confidence and accuracy. In contrast, data-independent regularizers are at the core of Bayesian learning, enforcing adherence of the variational distribution in the model parameter space to a prior density. The former approach is unable to quantify epistemic uncertainty, while the latter is severely affected by model misspecification. In light of the limitations of both methods, this paper proposes an integrated framework, referred to as calibration-aware Bayesian neural networks (CA-BNNs), that applies both regularizers while optimizing over a variational distribution as in Bayesian learning. Numerical results validate the advantages of the proposed approach in terms of expected calibration error (ECE) and reliability diagrams.
BibTeX
@inproceedings{huang2023calibration,
  author = {Jiayi Huang and Sangwoo Park and Osvaldo Simeone},
  title = {{Calibration-Aware Bayesian Learning}},
  booktitle = {MLSP},
  year = {2023},
  url = {https://openreview.net/forum?id=f2Z4PJyRJP},
}

Loading related content...

Figure