Calibrating Deep Neural Network Classifiers on Out-of-Distribution Datasets

Zhihui Shao, Jianyi Yang, Shaolei RenarXiv 2020

Abstract

Deep Neural Networks (DNNs) are notoriously overconfident when facing out-of-distribution (OOD) data, often being "confidently wrong." This paper introduces CCAC (Confidence Calibration with an Auxiliary Class), a post-hoc method that adds a dedicated "misclassification" class to the calibration model. By treating errors as a distinct category, CCAC significantly improves the accuracy of confidence scores on unpredictable real-world datasets without requiring full model retraining.

Introduction

In an ideal scenario, a classifier's confidence should reflect its actual accuracy; a 90% confidence score should imply a 90% probability of being correct. This property, known as calibration, is often absent in modern DNNs. The problem escalates into a crisis when models encounter out-of-distribution (OOD) data—samples that differ from the training set due to environmental changes (e.g., weather effects on sensors) or adversarial attacks.

Existing post-hoc calibration methods, such as Temperature Scaling, typically rescale existing outputs but fail on OOD data because they do not account for the fundamental failure of the model's logic. This research aims to enable models to "know what they don't know" by providing a mechanism to identify and penalize misclassifications.

Methodology: The CCAC Framework

The authors propose CCAC (Confidence Calibration with an Auxiliary Class). Unlike standard methods that map $K$ logits to $K$ calibrated probabilities, CCAC maps the original $K$ logits to $K+1$ outputs.

  • The Auxiliary Class: The $(K+1)$-th class specifically represents "misclassified samples." During post-hoc training, if the original DNN misclassifies a sample, that sample is labeled as belonging to this auxiliary class.
  • Geometric Mean Confidence: To derive the final confidence score, CCAC fuses the probability of the predicted class with the probability that the sample is not misclassified using a geometric mean. This creates a single, more honest confidence value.
  • CCAC-S (Simplified): To address the high cost of labeling OOD data, a "Simplified" version uses standard temperature scaling for the first $K$ classes and a minimal neural network for the auxiliary class. This version can be transferred to new unseen datasets using as few as 320 labeled examples.
Figure 3: Comparison of confidence distributions for correct and wrong predictions across different calibration stages. Plot (e) demonstrates the superior separation achieved by CCAC, where wrong predictions are pushed toward zero confidence.

Experimental Evaluation

The researchers evaluated CCAC across diverse tasks:

  • Image Classification: VGG16 and ResNet-50 models were tested on CIFAR-10, CIFAR-100, and ImageNet, with OOD versions created via rotations, shifts, zooms, and adversarial attacks (DeepFool).
  • Document Classification: A Deep Average Network (DAN) was tested on Reuters-8 and 20 Newsgroups, using text augmentation (typos, word swaps) to generate OOD samples.

Results and Analysis

CCAC consistently outperformed state-of-the-art baselines like Temperature Scaling (TS) and Dirichlet Calibration. On CIFAR-10 OOD data, CCAC reduced the Expected Calibration Error (ECE) to 2.0%, a massive improvement over the 14.4% seen with Temperature Scaling and 24.3% for uncalibrated models.

Separation vs. Scaling

A key insight of this work is that misclassified OOD samples often cluster together in logit space. By treating "being wrong" as its own category, the calibration model learns to identify the signature of a failing DNN. Visualization via t-SNE confirms that while standard methods leave wrong and right samples mixed, CCAC effectively pushes misclassified samples into a low-confidence region.

Figure 1: t-SNE visualization showing the clustering of correct (yellow) and wrong (red) samples. CCAC helps isolate misclassified samples, allowing for better confidence penalization.

Beyond ECE, CCAC achieved significantly lower Brier scores and superior performance in misclassification detection (higher AUROC and AUPR), proving that it provides more useful probability estimates for downstream decision-making.

Conclusion

CCAC offers a robust solution for the "confidently wrong" problem in DNNs. While it requires a small amount of labeled OOD data for its simplified version (CCAC-S), its ability to transfer calibration logic across different types of data shifts makes it highly practical. Future work may focus on reducing label requirements further and exploring theoretical foundations for the geometric mean fusion approach.

Summary updated

BibTeX
@misc{shao2020calibrating,
  author = {Zhihui Shao and Jianyi Yang and Shaolei Ren},
  title = {{Calibrating Deep Neural Network Classifiers on Out-of-Distribution Datasets}},
  year = {2020},
  eprint = {2006.08914},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.08914},
}
Figure