[Paper Review] Neural Clamping: Joint Input Perturbation and Temperature Scaling for Neural Network Calibration
This paper proposes Neural Clamping, a novel post-processing calibration method that jointly learns a universal input perturbation and temperature scaling parameter to improve neural network calibration. By optimizing both input and output transformations simultaneously, Neural Clamping achieves state-of-the-art performance, reducing expected calibration error by 36% on ResNet-110 with CIFAR-100 compared to the best baseline.
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.
Motivation & Objective
- To address the critical issue of poor calibration in deep neural networks, especially in safety-critical applications like medical diagnosis and autonomous vehicles.
- To propose a new post-processing calibration framework that jointly optimizes input and output transformations, moving beyond traditional output-only calibration.
- To theoretically justify why joint calibration is provably better than temperature scaling alone in terms of constrained entropy maximization.
- To empirically validate that Neural Clamping significantly improves calibration across diverse models and datasets, including ResNet and RegNet on CIFAR-100 and ImageNet-1K.
Proposed method
- Neural Clamping applies a learnable universal input perturbation δ to all inputs and a learnable temperature scaling parameter T to the output logits of a pre-trained classifier.
- The parameters δ and T are jointly optimized by minimizing a focal loss with weight decay on a calibration dataset, enabling data-driven adaptation.
- The method includes a first-order approximation-based data-driven initialization for δ to improve training stability and convergence.
- During inference, the optimized δ* and T* are applied to inputs and logits respectively, without updating the original model parameters θ.
- The framework is compatible with any pre-trained K-class classifier and supports end-to-end calibration via backpropagation on the perturbation and temperature.
- Theoretical analysis proves that Neural Clamping achieves better constrained entropy maximization than temperature scaling alone, justifying its superiority.
Experimental results
Research questions
- RQ1Can joint input and output calibration outperform conventional post-processing methods that only adjust output logits?
- RQ2Is there a theoretical advantage to combining input perturbation with temperature scaling over temperature scaling alone?
- RQ3How does data-driven initialization of the input perturbation affect the stability and performance of the calibration process?
- RQ4To what extent does input calibration contribute to reducing calibration error when combined with output calibration?
- RQ5Does Neural Clamping generalize across different architectures and datasets, including ImageNet-1K and CIFAR-100?
Key findings
- Neural Clamping reduces expected calibration error (ECE) by 36% on ResNet-110 when calibrated on CIFAR-100 compared to the best-performing baseline.
- The method achieves a 29% further reduction in ECE when combining input and output calibration, demonstrating the additive benefit of joint optimization.
- Data-driven initialization of the input perturbation δ leads to significantly more stable training with lower variance across 5 runs, compared to random initialization.
- Neural Clamping maintains high accuracy (72.20% on RegNetY-400MF) while improving calibration metrics such as entropy and reducing ECE to 0.0107 with focal loss.
- On ResNet-110, Neural Clamping achieves an ECE of 0.0085, which is 29% lower than output-only calibration (0.0119) and 36% lower than the best baseline.
- The method outperforms state-of-the-art post-processing calibration techniques including temperature scaling, vector scaling, matrix scaling, and ODIR-based methods across all evaluation metrics on multiple models and datasets.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.