Abstract
HACk-OOD is a novel post-training method designed to detect out-of-distribution (OOD) samples by approximating the complex "contour" of in-distribution (ID) data using a collection of multidimensional hypercones. By moving away from rigid distributional assumptions like Gaussianity, HACk-OOD "shrink-wraps" the data manifold, achieving state-of-the-art performance on challenging benchmarks, particularly in the difficult "Near-OOD" detection task.
Introduction
Machine learning models are frequently overconfident, assigning high-confidence labels to data that lies outside their training distribution (OOD data). This behavior is a critical safety concern for applications such as autonomous driving and medical diagnosis. The primary challenge in OOD detection is accurately defining the boundary of the model's known feature space. Existing distance-based methods often assume ID data follows simple geometric shapes, such as hyperspheres or Gaussians. However, high-dimensional feature spaces typically contain irregular, "noodly" manifolds. Rigid boundaries often include significant empty space where OOD data can hide, leading to poor detection performance.
Methodology: HACk-OOD
The authors propose HACk-OOD (Hypercone Assisted Contour Generation for OOD Detection), a post-training, distance-based method that can be applied to any pre-trained classifier without retraining.
Hypercone Construction
The method operates on embeddings from the model's penultimate layer. For each class, a centroid is calculated to serve as the "apex" for a set of hypercones. Each ID training point defines an "axis" extending from this centroid. The boundary of each cone is defined by:
- Angular Boundary: The "width" or opening angle of the cone is determined by the distance to its $k$-th nearest neighbor, allowing the method to adapt to local data density.
- Radial Boundary: The "length" of the cone is based on the local distribution of points, specifically the mean plus two standard deviations.
A new sample is flagged as OOD if it falls outside the union of all constructed hypercones for all classes.
Adaptive $k$ Selection
To eliminate the need for an OOD validation set—which is often unavailable in practice—the authors introduce an Adaptive $k$ heuristic. This approach automatically selects the neighborhood size $k$ based on the local data structure, ensuring robustness across different datasets.
Experimental Results
HACk-OOD was evaluated using standard benchmarks, including CIFAR-10 and CIFAR-100 as ID data, with various Far-OOD (e.g., SVHN, Textures) and Near-OOD (e.g., ImageNet-R) datasets.
Performance Benchmarks
HACk-OOD achieved state-of-the-art (SOTA) results on the CIFAR-100 benchmark:
- Near-OOD Performance: Using a ResNet-50 backbone, it achieved an average FPR@95 of 76.06%, a significant improvement over previous baselines.
- Far-OOD Performance: It reached an average FPR@95 of 36.09% on CIFAR-100, outperforming the best baseline by 5.68%.
- Efficiency: Inference time is low, ranging between 1.0 and 4.5 ms per sample, making it suitable for real-time deployment.
Synergy with Contrastive Learning
The method performs exceptionally well when the underlying model is trained with Supervised Contrastive Learning. This training paradigm forces classes into tight, cone-like clusters in the feature space, which aligns perfectly with the geometric assumptions of HACk-OOD.
Discussion and Conclusion
HACk-OOD's distribution-agnostic approach allows it to capture irregular data manifolds that traditional methods miss. Ablation studies highlighted the importance of directional sensitivity; using actual ID data points as axes is essential for defining a tight boundary. While the Adaptive $k$ heuristic provides a robust starting point, future work will focus on further optimizing this parameter and exploring multiple anchor points per class to increase contour precision. Additionally, the hypercone framework offers potential for feature space explainability, helping researchers visualize the limits of a model's knowledge.
Summary updated