NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Detecting Out-of-Distribution Through the Lens of Neural Collapse

Litian Liu, Yao Qin

TL;DR

This paper introduces NCI (Neural Collapse Inspired OOD Detector), a fast and robust method for detecting out-of-distribution (OOD) samples by leveraging the geometric properties of deep neural networks. By recognizing that in-distribution features naturally align with model weight vectors and expand away from the origin—a phenomenon known as Neural Collapse—NCI achieves state-of-the-art detection performance across diverse datasets with the speed of a simple softmax baseline.

What Problem Does This Paper Address?

Deep learning models are notoriously overconfident, often assigning high-probability scores to inputs they have never seen before (OOD samples). For safe deployment in the real world, models must be able to say "I don't know."

Current OOD detection methods face a "generalization gap": an algorithm that works perfectly for small-scale datasets like CIFAR-10 often performs poorly on large-scale benchmarks like ImageNet, and vice versa. Furthermore, many high-performing "feature-space" methods are computationally expensive, requiring nearest-neighbor searches across the entire training set, which is impractical for time-critical applications. The authors seek a method that is both versatile (works across scales) and efficient (low latency).

Methods

The authors turn to Neural Collapse (NC), a phenomenon observed in deep classifiers trained past zero error. In this state, the last-layer features of a class "collapse" to their mean, and these class means form a symmetric geometric structure called a simplex Equiangular Tight Frame (ETF) that aligns perfectly with the classifier's weight vectors.

Building on this, they propose the Neural Collapse Inspired OOD Detector (NCI), which uses two complementary scores:

  1. pScore (Proximity Score): Instead of comparing a test sample to every training sample, NCI compares the centered test feature ($h - \mu_G$) to the weight vector ($w_c$) of the predicted class. This captures how well the sample fits the "ideal" geometric cluster for that class.
  2. Feature Norm Filtering: Theoretical Neural Collapse dictates that in-distribution (ID) features must expand in space to form the ETF structure. Consequently, ID samples tend to have larger norms than OOD samples. NCI uses an $L_1$ norm filter to prune out OOD samples that reside too close to the origin.
Figure 2. Framework Illustration. Left: On the penultimate layer, the centered ID clusters reside near their predicted class weight vectors (marked by stars) while OOD samples reside separated, as shown by UMAP. Middle: ID and OOD samples are separated by pScore (Equation 6), which measures feature proximity to weight vectors. Also, ID samples tend to be further from the origin, illustrated with L1 norms. Right: ID samples cluster near a simplex Equiangular Tight Framework, illustrated with black arrows denoting weight vectors. We detect OOD by thresholding on pScore, selecting blue-shaded hypercones centered at weight vectors, with OOD samples outside these areas. We also filter OOD samples characterized by smaller feature norms. Left & Middle present a practical off-the-shelf CIFAR-10 ResNet-18 classifier with OOD set SVHN. Right depicts our scheme on a three-class classifier with 2D penultimate space.

NCI is a post-hoc method, meaning it can be applied to any pre-trained model without retraining or access to the original training data (other than calculating a global feature mean).

Datasets

The authors evaluated NCI across a wide range of architectures (ResNet, DenseNet, ViT, Swin Transformer) and datasets:

  • In-Distribution (ID): CIFAR-10, CIFAR-100, and ImageNet-1k.
  • Out-of-Distribution (OOD): A diverse suite including SVHN, MNIST, Textures, Places365, iNaturalist, and the OpenOOD benchmarks (SSB-hard, NINCO, OpenImage-O).

Key Insights and Ideas

  • Centering is Crucial: The alignment between features and weight vectors only becomes clear after centering the features by the global training mean ($\mu_G$). Without this step, the clustering behavior is much harder to exploit for OOD detection.
  • Weight Vectors as Anchors: By using the last-layer weights as class prototypes, NCI avoids the high computational cost of k-Nearest Neighbor (kNN) methods while still capturing class-specific feature information.
  • Early Emergence: While "perfect" Neural Collapse requires long training, the trend toward collapse emerges very early. As shown in Figure 1, the gap in cosine similarity between ID and OOD samples opens up well before training is complete.
Figure 1. Centered ID samples tend to cluster near the pre- dicted class weight vectors, which are the last-layer weights of the corresponding class, as indicated by higher average cosine similarity (Equation 5) than OOD. This observation, inspired by the trend of Neural Collapse, emerges early in the training of this CIFAR-10 ResNet-18 classifier, with OOD set SVHN.
  • Geometric Expansion: The paper provides a geometric explanation for why OOD samples often have smaller feature norms: they lack the "incentive" provided by the training process to expand into the high-dimensional ETF structure required for optimal class separation.

Key Results

NCI demonstrates a superior balance of accuracy and speed compared to 13 other baseline methods:

  • Robustness: NCI is the only method that consistently ranks in the top three across both CIFAR and ImageNet benchmarks. It achieves an Average AUROC of 89.51%, outperforming strong competitors like ViM (88.16%) and Scale (88.15%).
  • Efficiency: NCI's inference latency is nearly identical to the simplest baseline (Maximum Softmax Probability). On ImageNet, it is roughly 1.5x faster than kNN and significantly faster than other feature-space methods like ViM.
Table showing that NCI achieves the highest average AUROC while maintaining latency comparable to the simplest MSP baseline.

Limitations and Future Work

  • Dependence on Clustering Strength: NCI's effectiveness is tied to how strongly a model exhibits Neural Collapse trends. On models with weaker ID clustering (like some ImageNet ResNet-50s), the norm-based filtering becomes much more critical.
  • Hyperparameter Sensitivity: While the authors show that the filtering strength $\alpha$ is relatively stable within a given scale, it still requires a small validation set (e.g., Gaussian noise) to tune.
  • Future Directions: The authors suggest exploring how these geometric insights could improve other areas like model calibration and adversarial robustness.

Summary updated

BibTeX
@misc{liu2023detecting,
  author = {Litian Liu and Yao Qin},
  title = {{Detecting Out-of-Distribution Through the Lens of Neural Collapse}},
  year = {2023},
  eprint = {2311.01479},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.01479},
}
Figure