Introduction
Detecting out-of-distribution (OOD) samples is a critical requirement for deploying robust deep learning models in real-world environments. When a model encounters data significantly different from its training distribution, it should ideally flag it as "unknown" rather than making a high-confidence incorrect prediction. Current state-of-the-art methods, such as ODIN and the Mahalanobis detector, often rely on Global Average Pooling (GAP) to summarize feature maps. However, GAP collapses spatial information into a single scalar, discarding structural patterns that are often discriminative for OOD detection. Furthermore, many existing methods require OOD samples for hyperparameter tuning, which is often impractical.
Methodology: The MALCOM Framework
The proposed method, MALCOM (MAhaLanobis distance with COMpression complexity pooling), introduces Compression Complexity Pooling (CCP) to preserve spatial information without significant computational overhead.
The pipeline consists of three primary stages:
- Quantization and Linearization: Continuous feature maps are discretized using Lloyd-Max quantization. To preserve spatial locality, a Hilbert space-filling curve is used to flatten the 2D maps into 1D strings.
- Normalized Compression Distance (NCD): NCD is a parameter-free metric used to measure similarity between the linearized feature maps of a test sample and "prototypical" maps derived from the training data. Lower NCD scores indicate higher similarity in spatial patterns.
- Complexity Pooling: Instead of simple averaging, CCP generates a distance vector based on NCD values, capturing the complexity and spatial arrangement of features.
These CCP features are integrated with standard GAP features, and a Mahalanobis distance-based score is calculated to identify OOD samples.
Experimental Results
The effectiveness of MALCOM was evaluated across several benchmarks, including CIFAR-10, CIFAR-100, and SVHN as in-distribution (ID) datasets, with TinyImageNet, LSUN, and iSUN as OOD datasets.
Key findings include:
- Superior Performance: MALCOM consistently outperforms standard Mahalanobis and ODIN methods, particularly in "constrained" settings where no OOD data is used for tuning. For instance, on a DenseNet model trained on CIFAR-100, MALCOM achieved an AUROC of 96.76% for SVHN detection, significantly higher than the 91.61% achieved by the vanilla Mahalanobis approach.
- Spatial Pattern Sensitivity: The authors observed that while the average value of a feature map might look similar for both ID and OOD data, the arrangement of those values is often very different. CCP is particularly effective in earlier network layers, where spatial arrangements of textures and simple shapes are highly informative.
- Robustness of Prototypical Maps: Using prototypical maps as references for NCD calculation proved more stable and computationally efficient than comparing against random training samples.
Conclusion
MALCOM addresses two major limitations in OOD detection: the loss of spatial information due to GAP and the reliance on OOD validation sets. By leveraging compression complexity, the method captures rich structural patterns that are often overlooked. While calculating NCD introduces some computational cost, the gains in detection accuracy and the elimination of the need for OOD tuning make it a compelling approach for reliable machine learning systems.
Summary updated