Abstract
Class-wise training losses often diverge due to varying levels of intra-class and inter-class appearance variation. This divergence is a primary cause of uncalibrated predictions and overconfidence in deep learning models. To address this, we propose a novel post-hoc calibration method designed to synchronize class-wise training losses. By utilizing multiple class-wise scaling factors, our framework alleviates the variance of these losses without sacrificing overall model performance. Because the method compensates for over-fitted classes using information from under-fitted ones, the integrated training loss is preserved, maintaining accuracy while significantly improving reliability. Our approach is easily integrated into existing post-hoc calibration workflows, requiring minimal additional computation. We validate our framework across various benchmarks, demonstrating superior performance particularly in scenarios with unbalanced datasets and untuned hyperparameters.
Introduction
Modern deep neural networks (DNNs) have achieved state-of-the-art performance across numerous domains, yet they remain notoriously "uncalibrated." A model is considered well-calibrated if its predicted probability (confidence) matches the actual likelihood of being correct. For instance, if a model predicts a "cat" with 99% confidence, it should be correct 99% of the time. In practice, however, modern models are often overconfident, which poses significant risks in safety-critical applications like autonomous driving or medical diagnostics.
Existing solutions, such as Temperature Scaling (TS), typically apply a single global parameter to all classes. This approach is often too coarse, as different classes exhibit different levels of difficulty and intra-class variation. This paper identifies that the "asynchronous" behavior of class-wise losses—where some classes overfit quickly while others remain under-fitted—is a fundamental driver of poor calibration.
The Relationship Between Loss Variance and Calibration
The core insight of this research is the discovery of a strong linear correlation between the variance of class-wise training losses and the Expected Calibration Error (ECE). The authors demonstrate that as the spread of losses between different classes increases, the model's calibration tends to degrade. This suggests that synchronizing these losses could be a key lever for improving model reliability.
Methodology: Class-wise Loss Scaling (SCTL)
The proposed framework, Class-wise Loss Scaling (SCTL), is a post-hoc method that adjusts the outputs (logits) of a pre-trained model using a small validation set. The process involves several key steps:
- Normalization: Class-wise losses are normalized to a distribution with zero mean and unit standard deviation. This allows the system to evaluate the relative confidence levels across the entire dataset.
- Sigmoid-based Weighting: The method introduces class-specific scaling factors ($w_i$). These weights are governed by a sigmoid-based function controlled by two learnable parameters, $\alpha$ and $\beta$.
- Synchronization: The optimization process focuses on finding the optimal $\alpha$ and $\beta$ to minimize the variance of the class-wise losses. This effectively "synchronizes" the losses by compensating for over-fitted classes (low loss) with information from under-fitted classes (high loss).
- Preservation of Accuracy: Because SCTL balances the losses rather than simply suppressing them, the integrated training loss remains stable. This prevents the accuracy drops that often plague other calibration techniques.
Experimental Evaluation
The researchers evaluated SCTL across a variety of architectures (DenseNet, ResNet, WideResNet) and datasets:
- Standard Benchmarks: CIFAR-10, CIFAR-100, and ImageNet.
- Imbalanced Benchmarks: CIFAR-10-LT and CIFAR-100-LT (Long-Tailed versions), which simulate real-world data imbalances.
Key Results
- State-of-the-Art Calibration: SCTL consistently outperformed baseline methods. On CIFAR-10, it reduced the average ECE from approximately 0.97% (using standard Temperature Scaling) to 0.72%.
- Success in the "Long Tail": The method's greatest strength was observed in imbalanced datasets. On CIFAR-10-LT, SCTL achieved an ECE of 3.06%, a massive improvement over the uncalibrated baseline (21.08%) and standard TS (6.11%).
- Scalability to ImageNet: On the large-scale ImageNet dataset, SCTL improved calibration where other modern methods, such as Focal Loss, occasionally caused performance to degrade.
- Robustness: The framework proved robust across different architectures and required minimal hyperparameter tuning, making it a practical choice for diverse deployment scenarios.
Discussion and Limitations
SCTL offers a stable alternative to methods like Focal Loss or Label Smoothing, which can sometimes diverge or require complex learning rate schedules. By aligning with standard cross-entropy trajectories, SCTL provides a more predictable path to calibration.
However, the method has certain limitations. It is dependent on the availability of logits; if a pre-trained model only outputs hard labels or final probabilities, SCTL cannot be applied directly. Additionally, while the computational overhead is significantly lower than retraining a model, it does introduce a small optimization step during the post-hoc phase.
Conclusion
By shifting the focus from global error to class-wise loss variance, SCTL provides a nuanced and effective approach to model calibration. It successfully reduces overconfidence without sacrificing predictive accuracy, particularly in the challenging context of imbalanced data. Future work may involve extending this synchronization logic to other domains such as natural language processing and object detection.
Summary updated