Neural Clamping: Joint Input Perturbation and Temperature Scaling for Neural Network Calibration
Yung-Chen Tang, Pin-Yu Chen, Tsung-Yi Ho
TL;DR
This paper tackles the problem of neural network calibration, aiming to align prediction confidences with true probabilities in a post-processing setting. It introduces Neural Clamping, a joint input-output calibration method that learns a universal input perturbation $\bm{\delta}$ and a temperature $T$ to recalibrate a frozen classifier, optimized on a calibration set with focal loss. The authors establish a theoretical justification showing that this joint approach maximizes entropy relative to plain temperature scaling and provide a data-driven rule for initializing $\bm{\delta}$, along with an efficient training variant. Empirically, Neural Clamping consistently achieves state-of-the-art calibration across BloodMNIST, CIFAR-100, and ImageNet over diverse architectures, often reducing both $\text{ECE}$ and $\text{AECE}$ by substantial margins and sometimes improving accuracy, demonstrating strong practical impact for reliable uncertainty estimation.
Abstract
Neural network calibration is an essential task in deep learning to ensure consistency between the confidence of model prediction and the true correctness likelihood. In this paper, we propose a new post-processing calibration method called Neural Clamping, which employs a simple joint input-output transformation on a pre-trained classifier via a learnable universal input perturbation and an output temperature scaling parameter. Moreover, we provide theoretical explanations on why Neural Clamping is provably better than temperature scaling. Evaluated on BloodMNIST, CIFAR-100, and ImageNet image recognition datasets and a variety of deep neural network models, our empirical results show that Neural Clamping significantly outperforms state-of-the-art post-processing calibration methods. The code is available at github.com/yungchentang/NCToolkit, and the demo is available at huggingface.co/spaces/TrustSafeAI/NCTV.
