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

Md Yousuf Harun, Jhair Gallardo, Christopher Kanan

TL;DR

Deep neural networks face a hidden architectural trade-off: feature spaces that collapse into tight clusters excel at detecting out-of-distribution (OOD) data but fail at transferring knowledge to new domains. This paper resolves this conflict by strategically controlling "Neural Collapse" at different layers—using an entropy-regularized encoder to preserve feature diversity for transfer learning, paired with a fixed geometric projector to force collapse for robust OOD detection.

What Problem Does This Paper Address?

When deploying deep learning models in the real world, they must be both cautious and adaptable. They need Out-of-Distribution (OOD) detection to reject unfamiliar inputs and avoid overconfident blunders, and OOD generalization (transfer learning) to adapt their learned knowledge to new distributions.

Historically, these two capabilities have been studied in isolation. This paper unifies them by looking through the lens of Neural Collapse (NC)—a phenomenon where the final layers of a network compress within-class features into highly compact, symmetrical clusters.

The authors discover a fundamental dilemma: strong Neural Collapse is a blessing for OOD detection because it creates clean, well-separated boundaries between known classes. However, it is a curse for OOD generalization because this extreme compression destroys feature diversity (known as the Tunnel Effect), leaving the model with no generic features to transfer to novel tasks.

Figure 1: In this paper, we show that there is a close inverse relationship between OOD detection and generalization with respect to the degree of representation collapse in DNN layers. This plot illustrates this relationship for VGG17 pre- trained on ImageNet-100 using four OOD datasets, where we measure collapse and OOD performance for various lay- ers. For OOD detection, there is a strong positive Pearson correlation (R = 0.77) with the degree of neural collapse (NC1) in a DNN layer, whereas for OOD generalization, there is a strong negative correlation (R = −0.60). We rigorously examine this inverse relationship and propose a method to control NC at different layers.

As shown in Figure 1, there is a stark inverse relationship: as Neural Collapse intensifies, OOD detection error drops (strong positive correlation, $R=0.77$), but OOD generalization error climbs ($R=-0.60$). A single feature space simply cannot excel at both.

Methods

To bypass this trade-off, the authors propose a framework that decouples the representation spaces within a single network architecture.

Figure 2: Implication of Neural Collapse. Mitigating NC in the encoder enhances OOD generalization whereas increasing NC in the projector improves OOD detection.

As illustrated in Figure 2, the network is split into two primary components:

  1. The Encoder (For Generalization): The backbone network is trained to mitigate Neural Collapse. To do this, the authors introduce an entropy regularization loss ($L_{reg}$) based on data-driven nearest-neighbor distances. By maximizing the differential entropy of the embeddings, the encoder is forced to maintain high feature diversity and utilize all available dimensions. Additionally, standard Batch Normalization is replaced with a combination of Group Normalization and Weight Standardization to eliminate harmful batch dependencies under distribution shifts.
  2. The Projector (For Detection): Positioned after the encoder, a multi-layer perceptron (MLP) projector is explicitly designed to induce Neural Collapse. Instead of learning these weights, the authors fix and freeze them into a Simplex Equiangular Tight Frame (ETF)—a rigid, mathematically optimal geometric structure where class means are maximally distant on a hypersphere.

At test time, the diverse encoder embeddings are extracted for downstream transfer learning tasks, while the collapsed projector embeddings are used alongside an energy-based scoring function for OOD detection.

Datasets

The models were trained and evaluated using a rigorous protocol:

  • In-Distribution (ID) Dataset: ImageNet-100 (a 100-class subset of ImageNet-1K) was used for primary training. A smaller ImageNet-10 subset was utilized for training dynamics analysis.
  • OOD Datasets (8 benchmarks): To evaluate both detection and generalization, the authors tested on NINCO, ImageNet-R, CIFAR-100, Oxford 102 Flowers, CUB-200, Aircrafts, Oxford-IIIT Pets, and STL-10.

Crucially, the problem setup evaluates semantic OOD detection without granting the model access to any auxiliary OOD data during training.

Key Insights and Ideas

  • Entropy is the Control Knob for Collapse: The authors mathematically prove and empirically demonstrate that the differential entropy of class embeddings diverges to $-\infty$ as Neural Collapse occurs. Maximizing entropy directly counteracts feature compression (Figure 4).
  • Architectural Inductive Biases Over Plasticity: Instead of forcing a network to learn to collapse via complex loss functions, simply freezing a projector into a Simplex ETF configuration acts as a powerful architectural constraint that guarantees optimal class separation.
  • Visualizing the Split: UMAP visualizations (Figure 3) reveal the success of this decoupling: the encoder embeddings remain beautifully distributed and continuous (ideal for transfer), while the projector embeddings snap into perfectly isolated, compact islands.
Figure 3: UMAP Visualization of Embedding. The projec- tor embeddings exhibit much greater NC (NC1 = 0.393) than the encoder embeddings (NC1 = 2.175) as indicated by the formation of compact clusters around class means. For clarity, we highlight 10 ImageNet classes by distinct colors. For this, we use ImageNet-100 pre-trained VGG17.

Key Results

The decoupled approach consistently achieves the "best of both worlds" across multiple architectures (VGG17, ResNet18/34, and ViT-Tiny/Small):

  • Detection vs. Generalization Split: Within the same model, the projector outperformed the encoder in OOD detection by margins of 7.73% to 22.52%, while the encoder beat the projector in transfer capability by 10.90% to 24.51%.
  • Beating the State-of-the-Art: When compared to NECO (a SOTA Neural Collapse-based OOD detector), the proposed method reduced the average OOD detection error by an absolute margin of 12.72% for VGG17 and 18.43% for ResNet18.
  • Negligible Overhead: Despite the dual-space optimization, the framework introduces less than a 0.3% increase in training time and FLOPs compared to standard baseline models, making it highly scalable.

Limitations and Future Work

While highly effective, the authors note a few avenues for improvement:

  • Modality Constraints: The empirical validation was exclusively conducted on computer vision tasks. Extending this framework to audio, text, and multi-modal models remains an open challenge.
  • Task Scope: The method was designed around classification; future work is required to adapt fixed ETF projectors to regression or object detection frameworks.
  • Advanced Entropy Estimation: The current framework relies on a non-parametric nearest-neighbor density estimator for entropy regularization. Exploring parametric or adaptive approaches could yield more robust regularization.

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