Hypercone Assisted Contour Generation for Out-of-Distribution Detection

Annita Vapsi, Andrés Muñoz Garza, Nancy Thomas, Keshav Ramani, Daniel Borrajo · Submission to ICLR 2025 · Rejected

TL;DR

Existing distance-based out-of-distribution (OOD) detection methods often rely on rigid parametric assumptions (such as Gaussian distributions) or a single, uniform distance threshold across the feature space. HACk-OOD introduces a non-parametric contour-generation method that wraps in-distribution (ID) representations inside a union of multidimensional hypercones radiating from class centroids. Combined with pattern-memorized centroids (HACk-OOD+SHE), it achieves state-of-the-art performance on Near-OOD and Far-OOD detection on the challenging CIFAR-100 benchmark without modifying model training.

What Problem Does This Paper Address?

When deploying machine learning models, reliably detecting whether an input comes from an unfamiliar distribution (OOD) is critical for safety. Post-training, distance-based approaches assess OOD status using representations extracted from the model's penultimate layer.

However, existing techniques face a fundamental dilemma:

  1. Parametric methods (e.g., Mahalanobis distance, SSD+) assume ID representations follow Gaussian distributions, constraining decision boundaries to ellipsoids or hyperspheres that fail to capture irregular or non-convex feature manifolds.
  2. Non-parametric methods (e.g., k-NN) make fewer distributional assumptions, but typically apply a single, uniform distance threshold across the entire space, ignoring directional variation in density and spread.

Methods

HACk-OOD models class contours by constructing a collection of multidimensional hypercones per class in the feature space:

              Class Centroid (Apex)
                      / \
                     / . \  <-- Opening Angle (k-NN cosine distance)
                    /  .  \
                   /   .   \  <-- Axis: Vector to ID training sample
                  /____.____\
                       ^
                       Radial Boundary (mean + 2*sigma normalized distance)
  1. Centroid and Axes Placement: For each class, a centroid acts as the common apex. Each training instance defines an axis extending outwards from this apex. When features are normalized on a unit hypersphere, the centroid is chosen as the nearest training sample in cosine distance to prevent it from falling outside non-convex cluster boundaries.
  2. Angular Boundaries via Nearest Neighbors: The opening angle of each hypercone is defined by the cosine distance from its axis to its $k$-th nearest training neighbor in that class. This guarantees that each hypercone contains at least $k$ local points.
  3. Direction-Specific Radial Limits: For all samples within a hypercone's angular span, the method computes Euclidean distances from the centroid and sets an initial radial cutoff at $\mu + 2\sigma$ to suppress extreme outliers.
  4. Level-Set Scoring and Inference: Distances are normalized by these radial cutoffs. The 95th-percentile normalized score establishes a decision threshold $\lambda$ (targeting a 95% true positive rate). During inference, a test point is classified as ID if it falls within both the angular and radial boundary of any constructed hypercone across all classes.
  5. HACk-OOD+SHE: To mitigate noisy centroids caused by misclassified training samples, the authors substitute class centroids with stored pattern representations derived from Simplified Hopfield Energy (SHE).
  6. Adaptive $k$: An automated heuristic scales $k$ by accounting for feature dimensionality, class sample size, and local point density relative to a uniform distribution.

Datasets

  • In-Distribution (ID): CIFAR-100 (primary focus) and CIFAR-10.
  • Far-OOD Benchmarks: Textures, iSUN, LSUN, Places365, and SVHN.
  • Near-OOD Benchmarks (CIFAR-100): LSUN-Fix (LSUN-F), ImageNet-Fix (ImageNet-F), ImageNet-Resize (ImageNet-R), and CIFAR-10.
  • Models: ResNet-18, ResNet-34, and ResNet-50 architectures trained using Supervised Contrastive Learning (NT-Xent loss) and standard Cross-Entropy Loss.

Key Insights and Ideas

  • Local Directional Adaptability: Rather than imposing a single global boundary, hypercones adaptively expand or contract along specific directions based on local data density.
  • Data Samples as Coordinate Axes: Orienting hypercones along actual training observations concentrates coverage where data exists. Ablations show that using random uniform directions increases FPR95 by 14.36% on CIFAR-100 and 64.42% on CIFAR-10.
  • Capacity Synergy: Unlike Gaussian-based methods (which degrade in complex representations), HACk-OOD’s gains grow alongside network capacity. Larger backbones (ResNet-50) produce nuanced sub-cluster structures that hypercones trace effectively.
  • Incompatibility with ReAct: Combining HACk-OOD with activation truncation (ReAct) degrades performance significantly (e.g., FPR95 degrades from 34.29% to 94.77% on ResNet-50), because both mechanisms redundantly limit outward contour expansion.

Key Results

  • CIFAR-100 Far-OOD (ResNet-50, Supervised Contrastive): HACk-OOD+SHE attains 35.91% FPR95 and 91.95% AUROC, establishing a 10.03% reduction in FPR95 and a 2.47% boost in AUROC over the strongest baseline (SCALE/ASH).
  • CIFAR-100 Near-OOD (ResNet-50, Supervised Contrastive): HACk-OOD+SHE delivers 73.89% FPR95 and 80.41% AUROC, surpassing the best baseline by 6.81% in FPR95 and 2.27% in AUROC.
  • Inference Latency: Highly practical for post-hoc scoring, requiring 0.95 ms to 2.22 ms per sample across ResNet backbones on a standard 16-core CPU server.

Limitations and Future Work

  • Training Loss Dependency: While HACk-OOD can operate on cross-entropy models, its strongest gains rely on contrastive representations, where classes form tight, well-separated directional clusters.
  • Heuristic Parameterization: The hyperparameter $k$ and the preliminary radial cutoff ($\mu + 2\sigma$) are currently selected via empirical heuristics rather than theoretical optimization.
  • Future Directions: The authors suggest deriving formal optimal selection criteria for $k$ and radial limits, investigating alternative centroid estimations, and applying hypercone contour modeling to downstream classification and feature interpretability.

Summary updated

BibTeX
@misc{vapsi2025hypercone,
  author = {Annita Vapsi and Andrés Muñoz Garza and Nancy Thomas and Keshav Ramani and Daniel Borrajo},
  title = {{Hypercone Assisted Contour Generation for Out-of-Distribution Detection}},
  year = {2025},
  eprint = {2501.10209},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.10209},
}
Figure