Controlling Neural Collapse Enhances Out-of-Distribution Detection and Transfer Learning

Md Yousuf Harun, Jhair Gallardo, Christopher Kanan

Introduction

Deep neural networks are increasingly deployed in real-world environments where they must navigate data that differs significantly from their training sets. This requirement manifests in two distinct objectives: Out-of-Distribution (OOD) detection, the ability to identify and reject alien inputs, and OOD generalization (or transfer learning), the ability to adapt learned features to new, shifted domains. Historically, these goals have been treated as separate research tracks. However, this paper identifies a fundamental tension between them rooted in the geometric phenomenon of Neural Collapse (NC).

The Neural Collapse Trade-off

Neural Collapse occurs during the terminal phase of training when the within-class feature variance shrinks to zero, and the class means align into a symmetric geometric structure known as a Simplex Equiangular Tight Frame (ETF). While this "collapse" is beneficial for OOD detection—as it creates highly compressed, well-separated clusters that make anomalies easier to spot—it is detrimental to generalization. By squashing features into rigid class-specific points, the network discards the rich, diverse information necessary for transferring knowledge to downstream tasks.

This research provides the first unified theoretical and empirical evidence that OOD detection and generalization are inversely related to the degree of NC. Because standard architectures rely on a single feature space for both tasks, they are forced into a sub-optimal compromise.

Proposed Methodology: Decoupling Feature Spaces

To resolve this dilemma, the authors propose a dual-purpose architecture that strategically controls NC at different stages of the network. The core idea is to decouple the features used for transfer learning from those used for anomaly detection.

1. The Encoder: Mitigating NC for Generalization

To preserve feature diversity in the encoder, the authors introduce entropy regularization. By maximizing the differential entropy of the feature distribution—specifically by maximizing the distance between nearest-neighbor features in a training batch—the model prevents features from collapsing into single points. Mathematically, the authors demonstrate that as NC occurs, differential entropy approaches negative infinity; thus, penalizing low entropy effectively halts collapse. Additionally, the authors replace standard Batch Normalization with Group Normalization (GN) to eliminate batch-wise dependencies that often hinder OOD transfer.

2. The Projector: Inducing NC for Detection

To maximize OOD detection performance, the authors append a frozen, two-layer MLP "projector" to the encoder. Unlike the encoder, the projector is designed to enforce perfect NC. Its weights are mathematically fixed to a Simplex ETF structure, providing a structural guarantee for class separability. By applying $L_2$ normalization to the projector's output, the model forces features into tight, equinorm clusters, creating an ideal environment for distance-based OOD detection.

During inference, the encoder’s high-entropy output is utilized for downstream transfer tasks, while the projector’s collapsed output is used to calculate OOD scores.

Experimental Results

The framework was evaluated using ImageNet-100 for in-distribution training and a suite of eight diverse OOD datasets, including NINCO, ImageNet-R, and CIFAR-100. The experiments spanned multiple architectures, including VGG17, ResNet18, and Vision Transformers (ViT).

Performance Gains

The decoupling strategy yielded significant improvements across the board:

  • VGG17 Performance: The proposed method improved OOD generalization by 7.69% (absolute) and reduced the OOD detection False Positive Rate (FPR95) by 29.82% (absolute) compared to standard training.
  • Internal Decoupling: In the VGG17 model, the encoder (low NC) achieved a 41.85% generalization error, while the projector (high NC) suffered at 66.36%. Conversely, the projector achieved a 65.10% FPR95 for detection, far superior to the encoder's 87.62%. This confirms that the two tasks require diametrically opposed feature geometries.
  • SOTA Comparison: The method outperformed NECO, a leading NC-based detection method, reducing average OOD detection error by 12.72% on VGG17 and 18.43% on ResNet18.

Computational Efficiency

A key advantage of this approach is its minimal overhead. The entropy regularization and the addition of a frozen projector add less than 0.3% to the total FLOPs and training time, making it a highly practical solution for large-scale models.

Conclusion and Future Work

By identifying and breaking the Neural Collapse trade-off, this work enables a single model to excel at both anomaly detection and transfer learning. The results suggest that architectural inductive biases—such as hardcoding optimal geometric structures like Simplex ETFs—are more effective than relying on the training process to learn them naturally.

Future research directions include extending this framework beyond computer vision to modalities like natural language processing and audio. Additionally, the authors suggest that the explicit control of feature geometry could be a vital tool for continual learning, where models must simultaneously detect novel concepts and retain transferable knowledge without catastrophic forgetting.

Summary updated

BibTeX
@inproceedings{harun2025controlling,
  author = {Md Yousuf Harun and Jhair Gallardo and Christopher Kanan},
  title = {{Controlling Neural Collapse Enhances Out-of-Distribution Detection and Transfer Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=8AGdUCdDyI},
}
Figure