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

RankFeat&RankWeight: Rank-1 Feature/Weight Removal for Out-of-Distribution Detection

Yue Song, Wei Wang, Nicu SebeIEEE TPAMI 2023

TL;DR

This paper introduces RankFeat and RankWeight, novel post-hoc methods for Out-of-Distribution (OOD) detection. By analyzing the singular value decomposition of feature and weight matrices, they demonstrate that OOD data exhibits a distinct rank-1 structure. Removing this dominant rank-1 component effectively separates OOD from in-distribution data, achieving state-of-the-art results.

What Problem Does This Paper Address?

Deploying machine learning models in real-world scenarios requires robust OOD detection – the ability to identify when a model encounters data it wasn't trained on. Current deep learning models often exhibit overconfidence, providing high-probability predictions even for unfamiliar inputs, which can lead to critical failures. Existing OOD detection methods often rely on complex training procedures or specific model architectures. This paper addresses the need for simpler, more generalizable post-hoc methods that can be applied to pre-trained models without requiring additional training data or modifications.

Methods

The core innovation lies in analyzing the Singular Value Decomposition (SVD) of feature matrices and model weight matrices. The authors observe a consistent pattern:

  • RankFeat: This method focuses on the high-level feature maps extracted by a deep neural network. They find that OOD feature matrices tend to have a significantly larger dominant singular value compared to in-distribution (ID) features. RankFeat works by computing the SVD of the feature matrix, identifying the largest singular value and its corresponding singular vectors, and then removing this "rank-1" component. The perturbed feature is then passed through the rest of the network to generate OOD scores.
  • RankWeight: Motivated by the success of RankFeat, the authors investigate whether a similar phenomenon exists in the model's parameters. They discover that pruning the rank-1 component from the weight matrix of a single deep layer also effectively distinguishes OOD data. RankWeight is also a post-hoc method that requires only one SVD computation per layer.

Both methods are designed to be computationally efficient and can be applied to pre-trained models. They also demonstrate that RankWeight can be combined with existing OOD detection techniques to further boost their performance.

Datasets

The authors evaluate their methods on several large-scale datasets:

  • ImageNet-1k: Used as the primary benchmark for training and evaluating models.
  • OOD Datasets:
    • iNaturalist
    • SUN
    • Places
    • Textures
    • Species (including Protozoa, Microorganisms, Plants, and Mollusks)
  • CIFAR100: Used for evaluating performance across different model architectures.
  • One-class CIFAR10: Used to assess performance in a more constrained OOD setting.

Key Insights and Ideas

  • The Dominant Rank-1 Component: The most striking insight is that the difference between ID and OOD data is heavily concentrated in the largest singular value of feature and weight matrices. This suggests that OOD data might be "simpler" or more "compact" in its representation within these matrices.
  • OOD Features are Less Informative: By removing the dominant rank-1 component, the OOD feature statistics become closer to those of random matrices, indicating they are less informative. This makes them easier to distinguish from the more structured and informative ID features.
  • Rank-1 is Key, Not Rank-n: Ablation studies show that removing only the rank-1 component is significantly more effective than removing higher-rank components, reinforcing the importance of this dominant factor.
  • Simplicity and Generality: The methods are remarkably simple and effective, requiring only SVD and matrix subtraction. They are also general, working across different network architectures (CNNs, Transformers) and depths.
  • Complementary Nature: RankFeat (operating on features) and RankWeight (operating on weights) are complementary and, when combined, achieve the best performance, suggesting they address different aspects of the OOD problem.

Key Results

  • State-of-the-Art Performance: RankFeat and RankWeight, especially when combined, achieve state-of-the-art results on the ImageNet-1k benchmark, reducing the average False Positive Rate (FPR95) to as low as 16.13% and achieving an Area Under the ROC Curve (AUROC) of 96.20%.
  • Significant Improvement: RankFeat alone reduces the average FPR95 by 17.90% compared to previous best methods.
  • RankWeight's Boost: When integrated with other OOD detection methods like GradNorm, ReAct, ASH, and VRA, RankWeight consistently improves their performance, demonstrating its utility as a plug-in module.
  • Efficiency: RankFeat can be accelerated using Power Iteration, offering a competitive trade-off between speed and accuracy. RankWeight incurs negligible additional computational cost during inference.

Limitations and Future Work

  • Theoretical Understanding: While the paper provides theoretical analysis and empirical evidence, the exact reasons why OOD data consistently exhibits a larger dominant singular value are still a subject of conjecture, though training dynamics are implicated.
  • Pruning Depth: The authors found that pruning only one layer with RankWeight is sufficient and that pruning more layers can degrade performance. This suggests that the "rank-1 abnormality" is most pronounced in the final layers.
  • Future Work: The authors suggest exploring more sophisticated fusion strategies for multi-scale features and investigating the theoretical underpinnings of the rank-1 phenomenon more deeply. The flexible compatibility of RankWeight also opens avenues for its integration into a wider range of machine learning tasks beyond OOD detection.

Summary updated

BibTeX
@article{song2023rankfeat,
  author = {Yue Song and Wei Wang and Nicu Sebe},
  title = {{RankFeat\&RankWeight: Rank-1 Feature/Weight Removal for Out-of-Distribution Detection}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2023},
}
Figure