Consistency-Guided Temperature Scaling Using Style and Content Information for Out-of-Domain Calibration

Wonjeong Choi, Jungwuk Park, Dong-Jun Han, Younghyun Park, Jaekyun Moon

Abstract

Deep neural networks often exhibit significant overconfidence when encountering data from "unseen" domains, a phenomenon that poses risks in safety-critical applications. While standard post-hoc calibration methods like Temperature Scaling (TS) perform well when test data matches the training distribution, they frequently fail under domain shift. This paper introduces Consistency-Guided Temperature Scaling (CTS), a novel post-hoc method that improves out-of-domain (OOD) calibration by enforcing prediction consistency across style and content variations. By leveraging source-domain data to simulate potential shifts, CTS effectively "softens" model predictions for samples sensitive to distribution changes, significantly reducing Expected Calibration Error (ECE) without requiring access to target domain data.

Introduction

Modern AI models are notoriously "uncalibrated": their confidence scores rarely align with their actual likelihood of being correct. For instance, a model might predict a class with 99% confidence but only achieve 70% accuracy on that specific subset of data. This discrepancy is particularly dangerous during domain shift—when a model trained on professional photographs is deployed on sketches or cartoons.

Standard calibration techniques, most notably Temperature Scaling (TS), typically optimize a single scalar parameter $T$ on a held-out validation set. However, because this validation set usually shares the same distribution as the training data, the resulting temperature is often insufficient for the unpredictable nature of OOD data. The challenge lies in calibrating for a target domain that is entirely unavailable during the calibration phase.

Methodology: Consistency-Guided Temperature Scaling

CTS is a post-hoc method, meaning it does not require retraining the underlying model. Instead, it optimizes the temperature parameter $T$ by enforcing prediction consistency across two distinct dimensions of image data: style and content.

1. Inter-domain Style Consistency

Using Adaptive Instance Normalization (AdaIN), the researchers swap the "style" (represented by feature statistics like mean and variance) of an image from one source domain with that of an image from a different source domain. The model is then penalized if its prediction changes solely due to this style swap. This forces the model to become less sensitive to the stylistic variations that often define different domains (e.g., the difference between a photo and a sketch).

2. Intra-class Content Consistency

To address variations within a specific class, the method perturbs the "content" of an image—defined as the style-normalized features—by adding Gaussian noise. The model is penalized if these minor content variations cause the prediction to fluctuate.

Optimization

The final temperature $T$ is learned by minimizing a total loss function that combines the standard Negative Log-Likelihood (NLL) with these two consistency losses. By doing so, the model learns a temperature that effectively "softens" predictions for samples that show high variance when their style or content is shifted, as these samples are the most likely to be overconfident errors.

Experimental Setup and Results

The authors evaluated CTS using a "leave-one-domain-out" protocol across four standard multi-domain benchmarks: PACS, Office-Home, Digits-DG, and VLCS. In this setup, the model is calibrated on three domains and tested on a fourth, completely unseen domain.

Key Findings

  • Superior Calibration: CTS consistently outperformed state-of-the-art OOD calibration methods. On the PACS dataset, it reduced the Expected Calibration Error (ECE) from 9.06% (Standard TS) to 4.31%. Similar improvements were seen in Office-Home (10.47% to 4.75%) and Digits-DG (12.55% to 6.53%).
  • Consistency as a Proxy: The research confirmed a strong correlation between prediction variance and miscalibration. Samples that are sensitive to style or content shifts are almost always the ones where the model is most overconfident.
  • Style vs. Content Dynamics: The importance of each consistency loss varies by dataset. In PACS, where domains are defined by drastic stylistic differences (e.g., Cartoon vs. Photo), style consistency is paramount. In Office-Home, which features a high number of classes (65), content consistency plays a more critical role.
  • Compatibility: CTS is highly flexible and can be combined with existing Domain Generalization (DG) training methods like MixStyle or DSU to provide a model that is both highly accurate and reliably calibrated.

Discussion and Limitations

While CTS represents a significant step forward in OOD reliability, it has some limitations. The method relies on two hyperparameters ($\lambda_1, \lambda_2$) to balance the style and content losses; while these can be tuned on a validation set, the optimal balance is dataset-dependent. Additionally, the current implementation relies on feature statistics from CNN layers (like ResNet). Future work is needed to determine how these techniques translate to Vision Transformers (ViTs), which process spatial information and global context differently than traditional convolutional networks. Finally, the pair-wise sampling required for style swapping introduces a slight computational overhead during the calibration phase compared to simple temperature scaling.

Conclusion

Consistency-Guided Temperature Scaling (CTS) offers a robust solution for the overconfidence of deep learning models in unseen environments. By using consistency as a proxy for calibration, CTS allows models to remain reliable even when the deployment domain differs significantly from the training data, all without requiring any prior knowledge of the target domain.

Summary updated

BibTeX
@inproceedings{choi2024consistency,
  author = {Wonjeong Choi and Jungwuk Park and Dong-Jun Han and Younghyun Park and Jaekyun Moon},
  title = {{Consistency-Guided Temperature Scaling Using Style and Content Information for Out-of-Domain Calibration}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i10.29041},
}
Figure