Abstract
Out-of-distribution (OOD) detection is critical to building reliable machine learning systems in the open world. Researchers have proposed various strategies to reduce model overconfidence on OOD data. Among them, ReAct is a typical and effective technique to deal with model overconfidence, which truncates high activations to increase the gap between in-distribution and OOD. Despite its promising results, is this technique the best choice for widening the gap? To answer this question, we leverage the variational method to find the optimal operation and verify the necessity of suppressing abnormally low and high activations and amplifying intermediate activations in OOD detection, rather than focusing only on high activations like ReAct. This motivates us to propose a novel technique called "Variational Rectified Activation (VRA)", which simulates these suppression and amplification operations using piecewise functions. Experimental results on multiple benchmark datasets demonstrate that our method outperforms existing post-hoc strategies. Meanwhile, VRA is compatible with different scoring functions and network architectures.
Introduction
Deep learning models are notoriously overconfident. When presented with images from categories they have never encountered—Out-of-Distribution (OOD) data—they frequently assign high-probability scores to known classes. This behavior represents a significant safety hurdle for real-world deployments in autonomous driving, medical diagnosis, and security systems.
A popular recent solution to this problem is ReAct, which "rectifies" activations by truncating abnormally high values in the penultimate layer of a network. The logic behind ReAct is that OOD samples often trigger extreme internal responses that lead to overconfidence. While ReAct is effective, it is largely a heuristic approach. This research asks a fundamental question: Is simple truncation the mathematically optimal choice for widening the gap between "known" and "unknown" data?
Theoretical Foundation: The Variational Approach
To move beyond heuristics, the authors employ the variational method to derive an optimal activation function from first principles. They define an objective function designed to find an operation $g(z)$ that satisfies two primary goals:
- Maximize the gap between In-Distribution (ID) and OOD activation expectations.
- Minimize the distortion to the original input to preserve the model's learned features for ID classification.
By solving this optimization problem, the researchers discovered that the theoretically "perfect" function does more than just cut off the top (as ReAct does). It also suppresses very low activations and, crucially, amplifies intermediate activations. This suggests that intermediate activations are the most informative for distinguishing ID from OOD data, while both very low and very high activations contribute to noise or overconfidence.
The VRA Framework
Because the exact probability distributions of OOD data are rarely known in advance, the authors introduced three practical versions of Variational Rectified Activation (VRA) to approximate the derived optimal curve:
- VRA: A piecewise function that sets activations below a threshold $\alpha$ to zero and caps activations above a threshold $\beta$.
- VRA+: This variant adds a hyperparameter $\gamma$ to "boost" or amplify the intermediate activations residing between $\alpha$ and $\beta$.
- VRA++: A more advanced variant that combines these rectified features with logit-level energy scores to create a highly discriminative OOD indicator.
Crucially, these are post-hoc strategies. They do not require retraining the model; instead, they are applied to the penultimate layer of a pre-trained network during the inference phase. To ensure robustness across different architectures, VRA uses adaptive thresholding based on quantiles (e.g., the 90th percentile of ID activations) rather than fixed values.
Experimental Evaluation
The authors evaluated VRA across several standard benchmarks and architectures:
- In-Distribution (ID): CIFAR-10, CIFAR-100, and ImageNet-1k.
- Out-of-Distribution (OOD): A diverse suite including SVHN, Textures, Places365, LSUN, iNaturalist, and SUN.
- Architectures: DenseNet-101, ResNet-50, VGG-16, MobileNetV3, and EfficientNetV2.
Key Results
VRA consistently outperformed existing methods like ReAct, Energy scoring, and KNN-based detection.
- ImageNet Performance: On a ResNet-50 trained on ImageNet, VRA+ achieved a False Positive Rate (FPR95) of 23.31%, a significant improvement over ReAct’s 31.43%.
- CIFAR Performance: On CIFAR-10, VRA+ reduced the average FPR95 to 15.85%, compared to 26.45% for ReAct.
- Compatibility: VRA is not just a standalone score; it acts as a preprocessing step that improves the performance of other scoring functions like Maximum Softmax Probability (MSP), ODIN, and Energy.
Discussion and Limitations
The research highlights the "sweet spot" of activations: intermediate values are the most reliable indicators of distribution membership. While VRA provides a strong theoretical and empirical framework, it does face certain limitations:
- Hyperparameter Sensitivity: VRA relies on three hyperparameters ($\eta_\alpha, \eta_\beta, \gamma$). While the authors use Gaussian noise as a proxy for OOD data to tune these, performance can vary if the proxy does not align with the actual OOD data.
- Functional Form: The current VRA uses a piecewise linear function to approximate the optimal curve. Future work may explore more complex functional forms, such as quadratic functions, to better match the theoretical derivation.
- Architectural Factors: The influence of Batch Normalization statistics on overconfidence remains an area for further investigation to fully decouple the effects of architecture from activation rectification.
Conclusion
VRA represents a significant step forward in OOD detection by providing a theoretical basis for activation rectification. By suppressing noise at both ends of the activation spectrum and amplifying the informative middle ground, VRA sets a new state-of-the-art for post-hoc OOD detection without the need for expensive model retraining.
Summary updated