Skip to content

Source Code for Our ICML-2025 Paper "Controlling Neural Collapse Enhances Out-of-Distribution Detection and Transfer Learning"

License

Notifications You must be signed in to change notification settings

yousuf907/NC-OOD

Repository files navigation

Neural Collapse and OOD Detection/Generalization

This repository is the official PyTorch implementation of Controlling Neural Collapse Enhances Out-of-Distribution Detection and Transfer Learning published at ICML 2025.

Useful links:
[ArXiv Camera Ready]
[Project Page]

Control NC Method Overview

Out-of-distribution (OOD) detection and OOD generalization are widely studied in Deep Neural Networks (DNNs), yet their relationship remains poorly understood. We empirically show that the degree of Neural Collapse (NC) in a network layer is inversely related with these objectives: stronger NC improves OOD detection but degrades generalization, while weaker NC enhances generalization at the cost of detection. This trade-off suggests that a single feature space cannot simultaneously achieve both tasks. To address this, we develop a theoretical framework linking NC to OOD detection and generalization. We show that entropy regularization mitigates NC to improve generalization, while a fixed Simplex Equiangular Tight Frame (ETF) projector enforces NC for better detection. Based on these insights, we propose a method to control NC at different DNN layers. In experiments, our method excels at both tasks across OOD datasets and DNN architectures.

Dependencies

The conda environment that we used for this project has been shared in the GitHub repository. The yml file environment.yml includes all the libraries. We have tested the code with the packages and versions specified in the yml file. Our ViT experiments require the timm library, pip install timm. We recommend setting up a conda environment using the environment.yml file:

conda env create -f environment.yml

Repo Structure & Descriptions

Citation

If you find our repository helpful, please cite our paper.

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

About

Source Code for Our ICML-2025 Paper "Controlling Neural Collapse Enhances Out-of-Distribution Detection and Transfer Learning"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published