Attended Temperature Scaling: A Practical Approach for Calibrating Deep Neural Networks

Azadeh Sadat Mozafari, Hugo Siqueira Gomes, Wilson Leão, Steeven Janny, Christian Gagné

TL;DR

Deep neural networks (DNNs) are often overconfident, leading to unreliable predictions in critical applications. This paper introduces Attended Temperature Scaling (ATS), a novel calibration method that improves upon existing Temperature Scaling (TS) by being more robust to small or noisy validation datasets and highly accurate models, thus enhancing trust in DNNs for real-world decision-making.

What Problem Does This Paper Address?

Deep Neural Networks (DNNs) have achieved remarkable accuracy across various domains like computer vision and medical diagnosis. However, a critical issue is their tendency to be "overconfident," meaning their predicted probabilities don't accurately reflect the true likelihood of an event. In high-stakes applications such as autonomous driving or medical diagnostics, this overconfidence can be dangerous. A system that claims high certainty for an incorrect prediction can lead to severe consequences. While methods like Temperature Scaling (TS) exist to calibrate these confidence scores, they falter when faced with practical challenges: small validation datasets (which are often all that's available or feasible to collect), noisy labels within those datasets (common in real-world data collection), or when the underlying DNN is already highly accurate (leaving few misclassified examples for TS to learn from). This paper aims to address these limitations by proposing a more robust and effective calibration technique.

Methods

The core contribution of this paper is Attended Temperature Scaling (ATS), an extension of the popular Temperature Scaling (TS) method. TS works by learning a single temperature parameter ($T$) that "softens" the output of the softmax layer, aiming to make the predicted probabilities better aligned with the true probabilities. The optimal $T$ is found by minimizing a calibration loss (like Negative Log Likelihood - NLL) on a validation set.

ATS builds upon TS by introducing a more sophisticated way of preparing the data for calibration. Instead of using the entire validation set as is, ATS divides it into $K$ subsets, where $K$ is the number of classes. Each subset $M_k$ is designed to represent the distribution of samples belonging to class $k$. Crucially, $M_k$ includes not only samples with the true label $y=k$ but also samples from other classes ($y \neq k$) that are deemed "close" to the decision boundary for class $k$. This is achieved by selecting samples whose predicted probability for class $k$ is above a certain threshold $\theta$. This "attending" to relevant samples, including those near the boundary, effectively increases the number of informative samples for calibration and makes the process more robust to noise.

For ATS, a new loss function, $L_{ATS}$, is proposed to find the optimal temperature parameter. This loss function treats each subset $M_k$ as a binary classification problem (class $k$ vs. not class $k$) and aims to minimize the dissimilarity between the softened softmax output for class $k$ and the true conditional probability of class $k$.

Datasets

The paper evaluates ATS on a variety of standard datasets and models:

  • Image Classification: CIFAR-10, CIFAR-100, SVHN, MNIST, Caltech-UCSD Birds, and ImageNet2012.
  • Medical Diagnosis: The ISIC dataset (Skin Lesion Analysis Towards Melanoma Detection), containing images of 7 different skin lesion types.

The authors also discuss the importance of validation set size and the impact of label noise, implicitly using these as experimental conditions rather than distinct datasets.

Key Insights and Ideas

  • TS's Brittleness: The paper clearly demonstrates that standard Temperature Scaling (TS) is not a one-size-fits-all solution. Its performance degrades significantly when validation sets are small, contain noisy labels, or when the model is already highly accurate (leading to very few misclassified samples).
  • The Power of "Attending": ATS's core innovation lies in its "attentive" data selection for calibration. By specifically focusing on samples near the decision boundary and those with high confidence for a particular class (even if mislabeled), ATS effectively creates a more informative and robust calibration set.
  • Robustness to Noise and Size: The theoretical and empirical results strongly suggest that ATS is inherently more robust to label noise and less sensitive to the size of the validation set compared to TS. This is a critical practical advantage for real-world applications where perfect data is rare.
  • Improved Decision Making: The application to skin lesion detection highlights how better calibration directly translates to more reliable decision-making systems, leading to more appropriate referrals to specialists and fewer missed diagnoses.

Key Results

  • Superior Calibration: ATS consistently outperforms TS and other measure-based calibration methods (like Matrix and Vector Scaling) across various datasets and models, achieving lower NLL and ECE scores. Table 1 shows ATS achieving the best calibration results for almost all experiments.
  • Robustness Demonstrated: Figures 3 and 4 visually confirm ATS's superior robustness. While TS's calibration performance deteriorates significantly with increasing label noise or decreasing validation set size, ATS maintains much better calibration.
  • Practical Application Success: In the skin lesion detection task, ATS significantly improved the reliability diagram (Figure 5), demonstrating its ability to better distinguish between correctly classified and misclassified samples, leading to a more trustworthy referral system.
  • Efficiency Preserved: ATS maintains the low time and memory complexity advantages of TS, as it only optimizes a single temperature parameter per class.

Limitations and Future Work

  • Hyperparameter $\theta$ Tuning: ATS introduces a new hyperparameter $\theta$ (the confidence threshold for selecting samples) that needs to be fine-tuned on the validation set. While the paper suggests a strategy for tuning $\theta$ based on model accuracy, it remains an additional parameter to consider.
  • Computational Cost: While ATS is efficient, it does involve a more complex data preparation step for each class subset compared to TS.
  • Future Work: The paper suggests that ATS can be further explored for other applications where reliable confidence estimates are crucial. The theoretical underpinnings of ATS could also be expanded upon. The authors also mention that the optimal $T$ value for ATS can be found by minimizing $L_{ATS}$ which leads to $S_{y=k}(x, T^*)$ approaching $Q(y=k|x)$, implying further theoretical analysis could be beneficial.

Summary updated

Abstract

Recently, Deep Neural Networks (DNNs) have been achieving impressive results on wide range of tasks. However, they suffer from being well-calibrated. In decision-making applications, such as autonomous driving or medical diagnosing, the confidence of deep networks plays an important role to bring the trust and reliability to the system. To calibrate the deep networks' confidence, many probabilistic and measure-based approaches are proposed. Temperature Scaling (TS) is a state-of-the-art among measure-based calibration methods which has low time and memory complexity as well as effectiveness. In this paper, we study TS and show it does not work properly when the validation set that TS uses for calibration has small size or contains noisy-labeled samples. TS also cannot calibrate highly accurate networks as well as non-highly accurate ones. Accordingly, we propose Attended Temperature Scaling (ATS) which preserves the advantages of TS while improves calibration in aforementioned challenging situations. We provide theoretical justifications for ATS and assess its effectiveness on wide range of deep models and datasets. We also compare the calibration results of TS and ATS on skin lesion detection application as a practical problem where well-calibrated system can play important role in making a decision.
BibTeX
@misc{mozafari2018attended,
  author = {Azadeh Sadat Mozafari and Hugo Siqueira Gomes and Wilson Leão and Steeven Janny and Christian Gagné},
  title = {{Attended Temperature Scaling: A Practical Approach for Calibrating Deep Neural Networks}},
  year = {2018},
  eprint = {1810.11586},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1810.11586},
}
Figure