Abstract
Deep Neural Networks (DNNs) are prone to high-confidence misclassifications when encountering out-of-distribution (OOD) data. Traditional detection methods, such as those based on Mahalanobis distance, rely on the simplifying assumption that feature activations follow a Gaussian distribution. This paper proposes Residual Flow, a novel normalizing flow architecture that models feature distributions as non-linear refinements of a Gaussian base. By capturing complex, non-Gaussian patterns without requiring classifier retraining, Residual Flow significantly improves OOD detection reliability across multiple benchmarks.
Introduction
A critical challenge in deploying deep learning models in safety-critical environments is their tendency to be "overconfident" on unfamiliar inputs. For instance, a model trained on dog breeds might incorrectly classify a galaxy with high confidence. Current state-of-the-art (SOTA) methods often model the density of internal feature activations to identify anomalies. However, the common assumption of Gaussianity in these activations is often an oversimplification of real-world, multi-modal, or skewed distributions.
Methods
The proposed method leverages Normalizing Flows (NF)—invertible mappings that transform simple distributions into complex ones. The authors introduce several key innovations to make NFs effective for OOD detection:
- Linear Flow as a Gaussian Base: The authors demonstrate that a linear normalizing flow is mathematically equivalent to fitting a Gaussian distribution, providing a principled baseline.
- Residual Flow Architecture: The model is structured as a series of non-linear "residual" blocks added to the initial linear mapping. This allows the network to first capture the broad Gaussian structure and subsequently learn the complex "residuals" that standard models miss.
- Stable Initialization: Non-linear components are initialized to zero. This ensures the model begins as a standard Gaussian model and gradually increases in expressiveness, preventing the training instabilities common in standard NFs.
Key Results
The Residual Flow method was evaluated using ResNet-34 and DenseNet-100 architectures on datasets including CIFAR-10, CIFAR-100, and SVHN. The results demonstrate a clear superiority over the Mahalanobis-based baseline:
- Detection Accuracy: On a ResNet trained on CIFAR-100, the True Negative Rate (TNR) for ImageNet OOD samples improved from 56.7% to 77.5% at a 95% True Positive Rate.
- AUROC Gains: Significant improvements in the Area Under the ROC curve were observed, such as a jump from 66.2% to 87.2% for ResNet on CIFAR-100 vs. LSUN.
- Training Stability: The residual formulation proved to be more stable than standard non-linear flows, as evidenced by the AUROC vs. Iterations metrics.
Discussion and Conclusion
Residual Flow offers a "plug-and-play" solution for OOD detection, requiring no retraining of the underlying classifier. While it introduces some computational overhead due to additional forward passes, the gains in detection reliability are substantial. The method's success highlights that while internal features are approximately Gaussian, the non-linear "leftover" information is highly discriminative. Future work may extend this approach to other domains such as natural language processing and medical diagnostics.
Summary updated