Pursuing Feature Separation based on Neural Collapse for Out-of-Distribution Detection

## Abstract

Abstract In the open world, detecting out-of-distribution (OOD) data, whose labels are disjoint with those of in-distribution (ID) samples, is important for reliable deep neural networks (DNNs). To achieve better detection performance, one type of approach proposes to fine-tune the model with auxiliary OOD datasets to amplify the difference between ID and OOD data through a separation loss defined on model outputs. However, none of these studies consider enlarging the feature disparity, which should be more effective compared to outputs. The main difficulty lies in the diversity of OOD samples, which makes it hard to describe their feature distribution, let alone design losses to separate them from ID features. In this paper, we neatly fence off the problem based on an aggregation property of ID features named Neural Collapse (NC). NC means that the penultimate features of ID samples within a class are nearly identical to the last layer weight of the corresponding class. Based on this property, we propose a simple but effective loss called OrthLoss, which binds the features of OOD data in a subspace orthogonal to the principal subspace of ID features formed by NC. In this way, the features of ID and OOD samples are separated by different dimensions. By optimizing the feature separation loss rather than purely enlarging output differences, our detection achieves SOTA performance on CIFAR benchmarks without any additional data augmentation or sampling, demonstrating the importance of feature separation in OOD detection. The code will be published.

## 1 Introduction

In the open world, deep neural networks (DNNs) encounter a diverse range of input images, including in-distribution (ID) data that shares the same distribution as the training data, and out-of-distribution (OOD) data, which has labels that are disjoint from those of the ID cases. Facing the complex input environment, a reliable network system must not only provide accurate predictions for ID data but also recognize unseen OOD data. This necessity gives rise to the critical problem of OOD detection [, ], which has garnered significant attention in recent years, particularly in safety-critical applications.

A rich line of studies detect OOD samples by exploring the differences between ID and OOD data in terms of model outputs [, ], features [, , ], or gradients [, ]. However, it has been observed that models trained solely on ID data can make over-confident predictions on OOD data, and the features of OOD data can intermingle with those of ID features [, ]. To develop more effective detection algorithms, a category of works focus on the utilization of auxiliary OOD datasets, which can significantly improve detection performance on unseen OOD data. One classical method, called Outlier Exposure (OE, []), employs a cross-entropy loss between the outputs of OOD data and uniformly distributed labels to fine-tune the model. Additionally, Energy [] proposes using the energy function as its training loss and designs an energy gap between ID and OOD data. Building on these proposed losses, recent works have concentrated on improving the quality of auxiliary OOD datasets through data augmentation [, , ] or data sampling [, , ] algorithms to achieve better detection performance.

Figure: Figure 1: Overview of our method. An example of a well-trained binary classification network, where $w_{i}$ denotes the $i$-th weight of the last fully connected layer. The features of ID samples within a class are nearly identical to the weight of the corresponding class, which is known as Neural Collapse. Based on this property, we propose to constrain OOD features to lie in dimensions orthogonal to the FC weight subspace to explicitly separate the feature manifold between ID and OOD data.
Refer to caption: extracted/5622337/image/overview_of_our_method_5_cropped.jpg

Existing losses designed for auxiliary OOD data primarily focus on increasing the output discrepancy between ID and OOD samples [, ]. However, NONE of these approaches consider enhancing the separability in the feature space. Insights from knowledge distillation [] and contrastive learning [] have demonstrated that optimizing compactness or dispersion in the feature space is equally or even more important than enforcing similar constraints in the output space. Furthermore, previous detection score function design has shown the importance of employing feature information [, , ], which can greatly improve detection performance. Therefore, when tackling the fine-tuning problem using auxiliary OOD data, we propose that it is crucial to separate the features between ID and OOD data, rather than merely enlarging their output differences.

Designing an effective feature separation loss for ID and OOD data is inherently challenging due to the diversity of OOD samples, which belong to various categories. This diversity results in a dispersion of their features and difficulty in describing their feature distribution. Consequently, common feature separation losses, such as maximizing the distance between the average features of different classes [] or increasing the Kullback-Leibler divergence between ID and OOD feature distributions [], are not suitable in our cases. Despite the intricate distribution of OOD features posing a significant obstacle, in this paper, we derive solutions from the properties of ID features.

A recent observation named Neural Collapse [] gives us an inspiration, which reveals that the penultimate features of ID samples within a class are nearly identical to the last fully connected (FC) layer’s weights of the corresponding class. Conversely, the features of OOD samples are scattered haphazardly throughout the feature space. A direct illustration (^1^11For binary classification, NC indicates that the angle between $w_{1}$ and $w_{2}$ should be $180\degree$. But in order to show the general case of higher dimensions, we depict an angle of $90\degree$ in the figure.) can be seen in Figure 1. Leveraging the property of ID features, we propose to constrain the features of OOD data on dimensions orthogonal to the subspace (denoted as $\mathbf{W}$) spanned by FC weights. The dimension of $\mathbf{W}$ equals to the number of ID categories, while the the overall feature space dimension is significantly larger. Consequently, there are numerous redundant dimensions available for OOD features, indicating the feasibility of our method. To pursue this orthogonality, we introduce a loss function named OrthLoss (ref. Eq3), which calculates the cosine similarity between OOD features and the weights of the final FC layer. By optimizing this simple yet effective loss to zero, we ensure that OOD features are distributed in entirely different dimensions from ID features, thereby enhancing their separability. Our approach utilizes the NC property of ID features, allowing us to avoid modeling OOD feature distributions while effectively segregating ID and OOD features. The overall method can be widely applied as a stronger baseline compared to OE [], and seamlessly integrated with other approaches like ATOM[], POEM[], etc[, ] by replacing the OE loss with our OrthLoss.

We conduct extensive experiments over representative OOD detection setups, achieving the SOTA performance without any data augmentation or sampling algorithms [, ] on CIFAR10 and CIFAR100 benchmarks. For example, on the CIFAR100 benchmark, by using our feature separation loss, we achieve the average FPR95 of $29.58\%$ and AUROC of $94.01\%$, outperforming the traditional OE [] method by $8.19\%$ on FPR95. Furthermore, our method exhibits a very stable performance while comparable methods like DAL [] struggle with a high fluctuation, as Sec 4.4 shows. The contribution of our paper is summarized as follows:

- •
We are the first to propose the concept of feature separation when using auxiliary OOD data to fine-tune models, while previous works pay more attention to the output separation, providing new insights into the design of OOD data loss functions.
- •
To overcome the difficulty caused by OOD data diversity, we propose a feature separation loss based on the neural collapse property of ID features, which constrains OOD features to lie in dimensions where ID features are scarcely distributed.
- •
Our SOTA detection performance on representative OOD detection settings verify the effectiveness of our feature separation loss, implying that our loss can be a stronger baseline for future researches.

## 2 Related work

Post-hoc Detection.
Given a model that is only trained by ID data, post-hoc detection approaches design score functions based on it to distinguish ID and OOD data. One type method named density-based [, , , , , ] is to explicitly model the ID data with some probabilistic models and flag test data in low-density regions as OOD samples. More popular approaches are to derive confidence score based on model outputs [, , ], features [, , , , , , , , ] or gradients [, , , , , ]. For example, the classical maximum softmax probability method [] utilizes the model output probability of the predicted class as a confidence score and then identifies samples with low scores as OOD data.

Contrastive Learning based Detection.
Different from post-hoc methods based on vanilla-trained models, such methods generally apply contrastive losses defined on ID data in the model training process to obtain better feature representations for OOD detection. For example, KNN+ [] utilizes the SupCon loss [], which encourages alignment of features within a class and dispersion of features of different classes, to train a network to obtain greater differentiation between ID and OOD samples. Besides, CSI[] contrasts original samples with their distributionally-shifted augmentations to improve detection performance. Recent advancements, such as CIDER [], combine a compactness loss to cluster samples near their class prototypes and a dispersion loss to maximize angular distances between different class prototypes, providing a more direct and clearer geometric interpretation for the disparity between ID and OOD samples.

Auxiliary OOD Data based Detection.
With access to part of OOD data, previous works design training algorithms to utilize auxiliary OOD data for OOD detection. One type method is to propose unsupervised training loss functions [, , ], such as the Kullback-Leibler divergence between OOD output probability and uniformly distributed label [], to fine-tune the model. Based on the proposed losses, another type is to select OOD data close to the decision boundary [] or conduct data augmentation through adversarial attack [, ] and model perturbations [] in the training process, which can tight the boundary so that pushing unseen OOD data far away from it. In general, using auxiliary OOD data in the training process can significantly improve detection performance, achieving better results compared with other detection approaches.

## 3 Method

### 3.1 Preliminary

OOD Detection Problem.
The framework for OOD detection is outlined as follows. We consider a classification problem involving $C$ classes, where $\mathcal{X}$ represents the input space and $\mathcal{Y}$ denotes the label space. The joint data distribution over $\mathcal{X}\times\mathcal{Y}$ is referred to as $D_{\mathcal{X}\mathcal{Y}}$. Let $f_{\theta}:\mathcal{X}\mapsto\mathcal{Y}$ be a model trained on samples drawn independently and identically distributed (i.i.d.) from $D_{\mathcal{X}\mathcal{Y}}$ with parameters $\theta$. Then, the distribution of ID data is the marginal distribution of $D_{\mathcal{X}\mathcal{Y}}$ over $\mathcal{X}$, denoted as $D_{in}$. Conversely, the distribution of OOD data is represented as $D_{out}$, whose label set does not intersect with $\mathcal{Y}$. The primary objective of OOD detection is to determine whether a test input $x$ originates from $D_{in}$ or $D_{out}$. Typically, this decision is made using a score function $S$ as follows:

$$ $G_{\lambda}(x)=\left\{\begin{aligned} &\text{ID}&\quad&\text{if}\ S(x,f)\geq \lambda,\\ &\text{OOD}&\quad&\text{if}\ S(x,f)\leq\lambda,\\ \end{aligned}\right.$ $$

where $\lambda$ is a threshold. Samples with scores higher than $\lambda$ are classified as ID data. The threshold is usually set based on ID data to ensure that a high fraction of ID data (e.g., 95$\%$) is correctly identified as ID samples.

Finetune Model with Auxiliary OOD Data. In this paper, we consider the task of using auxiliary OOD data to fine-tune the model [, , , ], which can effectively enlarge the discrepancy between ID and unseen OOD data. Let’s denote the auxiliary OOD dataset as $D_{out}^{aux}$, which is a subset of real OOD datasets but has different distributions from the test OOD datasets in the experiments for fair comparison. One classical method is the Outlier Exposure (OE, []), which designs an outlier exposure loss that calculates the cross-entropy function between OOD outputs and uniformly distributed labels. The equation is as follows:

$$ $\displaystyle L_{OE}(x)$ $\displaystyle=-\frac{1}{C}\sum_{j=1}^{C}\log f_{j}(x)$ (1) $$

where $f_{j}(x)$ denotes the $j$-th element of the model output $f(x)$. The final training objective of OE is to simultaneously minimize cross-entropy loss on ID data and outlier exposure loss on OOD data, which can be formalized as:

$$ $\min_{f}\mathbb{E}_{(x,y)\sim D_{in}}L_{CE}(x,y)+\lambda\mathbb{E}_{x\sim D_{ out}^{aux}}L_{OE}(x)$ (2) $$

where $\lambda$ is a hyper-parameter, usually set to $0.5$. This optimization problem is regarded as a basic setting in auxiliary OOD data approaches. Most of subsequent methods adopt the same or similar loss functions that encourage ID and OOD data to differ in the output space. For example, POEM [] designs a data sampling algorithm for efficient training, and DAL [] employs adversarial features to calculate the OE loss to minimize the generalization gap between auxiliary and real unseen OOD data.

### 3.2 Motivation

Previous works have focused on increasing the discrepancy between ID and OOD data in the output space, while in this paper, we propose to explicitly enlarge the disparity of their features. Intuitively, separating features of ID and OOD data should be beneficial to OOD detection compared to solely augmenting the output differences. Existing feature separation functions in other fields, such as the dispersion loss that enlarges the distance between the average features of different classes [, ], are not suitable for diverse OOD data since their features are dispersed instead of clustering around the mean. To design a separation loss that can handle the complicated distribution of OOD features, we delve into the property of ID features. A recent observation named NC [] gives us a new insight, which reveals that the penultimate features of ID samples within a class are nearly identical to the last layer weight of the corresponding class. This intriguing property has stimulated many fields of research, including low-dimensional characteristics of ID features [, ] and model generalization analysis [, ]. Particularly, several works employ the principal component spaces identified by NC to design score functions [, , , ], which demonstrates the large potential of NC applied in OOD detection.
We conduct empirical experiments on CIFAR10 to validate the NC property, as Figure LABEL:Vanilla_model shows. Furthermore, with the comparison of OOD features of vanilla and OE-trained model (Figure LABEL:Vanilla_model vs. Figure LABEL:OE-trained_model ), we discover that although the outlier exposure loss only optimizes the output of OOD samples, it implicitly changes the distribution of OOD features, making OOD features more clustered and far way from ID features. However, from the 3D visualization of features in Figure LABEL:OE-trained_model_3D, it can be observed that the features of OOD data almost lie in the same subspace as ID features, without taking advantage of the new dimension (z-axis) to further widen the ID-OOD difference. Based on the above observations, we then design a feature separation loss without modeling OOD feature distributions as follows.

### 3.3 Feature Separation Loss

Our key idea is to confine the features of OOD data to dimensions where ID features are sparsely distributed. Considering that the principal subspace of ID features is $C$-dimensional, as determined by the NC property, while the overall feature space has a significantly larger dimensionality, there exist ample redundant dimensions that can accommodate OOD features. In pursuit of our goal, a straightforward condition arises: $z^{T}w_{i}=0,i=1,2,...,C$, where $z$ denotes the normalized feature of OOD data, and $w_{i}$ denotes the normalized fully connected layer weight for class $i$. According to this condition, we devise an OrthLoss for OOD data, which computes the average absolute value of the cosine similarity between $z$ and $w_{i}$. The specific equation is as follows:

$$ $L_{Orth}=\frac{1}{C}\sum_{i=1}^{C}\left|z^{T}w_{i}\right|$ (3) $$

Through minimizing the $L_{Orth}$ loss, the OOD feature $z$ tends to be distributed in the dimensions that are orthogonal to $w_{i},i=1,2,...,C$. Figures LABEL:Our_model and LABEL:Our_model_3D illustrate the features of our model fine-tuned using $L_{Orth}$. As observed, the features of outlier samples are indeed distributed in different dimensions from $w_{i}$, resulting in a larger discrepancy between ID and OOD features. Except for the $L_{Orth}$ loss, we also propose an alignment loss that encourages ID features (denote as $z_{ID}$) within a class to align closely with the FC weight of their corresponding class (denote as $w_{y}$). We term this loss function as $L_{NC}$ as it promotes neural collapse phenomenon [], enabling ID features within a class more clustered. The formulation is as follows:

$$ $L_{NC}=-z_{ID}^{T}w_{y}$ (4) $$

Our empirical experiment in Sec 4.3 indicates that adding $L_{NC}$ in the training loss can further improve the detection performance. Combining the above two losses, the final optimization problem can be formulated as:

$$ $\min_{f}\mathbb{E}_{(x,y)\sim D_{in}}(L_{CE}+\alpha L_{NC})+\mathbb{E}_{x\sim D _{out}^{aux}}(\lambda L_{OE}+\beta L_{Orth})$ (5) $$

where $\alpha$ and $\beta$ are hyper-parameters, which are set to $1.0$ in our experiments, $\lambda$ maintains the common value in OE setting as $0.5$.

### 3.4 Overall Framework

Training.
Based on the optimization problem in Eq.5, we present the detailed training procedure as follows. Notably, the initial model for fine-tuning is not fully converged on the ID dataset, making the NC phenomenon less evident in the early training stages. Consequently, we propose a two-stage training process:

$$ Stage1: $\displaystyle\min_{f}\ L_{CE}+\lambda L_{OE}$ (6) Stage2: $\displaystyle\min_{f}\ L_{CE}+\lambda L_{OE}+\alpha L_{NC}+\beta L_{Orth}$ $$

In the first stage, we only utilize the cross-entropy and outlier exposure loss functions, similar to the OE method []. As long as the model tends to converge on the ID dataset, we then incorporate $L_{Orth}$ and $L_{NC}$ into the training loss. In our experiments, we adopt a straightforward division where each stage occupies half of the total training epochs.

Test. After fine-tuning the model with our losses, we propose a new score function to detect OOD samples. Since our method simultaneously optimizes the output and feature of OOD data, a more proper score function is the sum of the traditional MSP [] and the average cosine similarity between features and $w_{i}$. Mathematically, it can be expressed as:

$$ $S(x,f)=\max_{i}\frac{e^{y_{i}}}{\sum_{j}^{C}e^{y_{j}}}+\frac{1}{C}\sum_{i=1}^{ C}\left|z^{T}w_{i}\right|$ (7) $$

where $y$ denotes the model output $f(x)$. Our experiments in Sec 4.4 compare the performance of using our score function with only using the MSP score. The result indicates that our method also performs well under MSP score, but slightly better under our proposed score function.

## 4 Experiments

In this section, we first conduct experiments on CIFAR10 and CIFAR100 benchmarks to validate the superiority of our method in Sec 4.1. Then, we consider the hard OOD detection setting proposed in [] to further verify the effectiveness of our method in Sec 4.2. Subsequently, we evaluate our method under different settings in the ablation study section 4.3. In the last part, we discuss the fluctuation of performance, the influence of different score functions, and the numerical result of feature separation degree in Sec 4.4. To begin with, we introduce our experiment setups as follows. All the experiments are conducted on GPUs of NVIDIA GeForce RTX 4090.

OOD Datasets. We randomly choose 300K samples from the 80 Million Tiny Images [] as our auxiliary OOD dataset. And we adopt five routinely used datasets as the test OOD datasets, including SVHN [], LSUN [], iSUN [], Texture [] and Places365[], which have non-overlapping categories w.r.t. CIFAR datasets.

Pre-training Setups. We employ Wide ResNet-40-2 [] trained for 200 epochs, with batch size 128, init learning rate 0.1, momentum 0.9, weight decay 0.0005, and cosine schedule.

Fine-tuning Setups. For both CIFAR10 and CIFAR100 benchmarks, we adopt the model parameter of the 99th epoch in the pre-training process as our initial network parameters, and then add auxiliary OOD data to train the model for 50 epochs with ID batch size 128, OOD batch size 256, initial learning rate 0.07, momentum 0.9, weight decay 0.0005 and cosine schedule. At the 25th epoch, we add our proposed $L_{Orth}$ and $L_{NC}$ into the training loss. The overall training setting is the same as DAL [].

Compared Methods. We compare our method with post-hoc approaches, contrastive learning based methods, and auxiliary OOD data based methods. The post-hoc methods include MSP[], Energy[], Maha[], and KNN []. The contrastive learning based methods include CSI[], CIDER[], and KNN+[]. The auxiliary OOD data based methods include OE [], Energy-OE [], POEM [], and DAL []. For OE and Energy-OE, we adopt the same training setting as ours, since we have discovered that their recommended setting in the original paper performs much worse than our setting. For other methods, we adopt their suggested setups but unify the backbones for fairness.

Evaluation Metrics. We report two classical metrics in this paper: 1) FPR95: the false positive rate of OOD samples when the true positive rate of ID samples is at 95$\%$. 2) AUROC: the area under the receiver operating characteristic curve. A lower FPR95 and a higher AUROC indicate better detection performance.

### 4.1 Main Results

The main results are shown in Table1, where we report the FPR95 and AUROC across the considered real OOD datasets (^2^22The symbol ^∗ in the table means the results are cited from DAL []). Compared to methods based on vanilla or contrastive learning models, whose training datasets only contain ID samples, incorporating auxiliary OOD data into the training process can significantly reduce the FPR95 and improve the AUROC, indicating that this direction is valuable to explore. Compared to the classical OE approach [], our method reduces the average FPR95 by $0.87\%$ on CIFAR10 and $8.30\%$ on CIFAR100, just by adding our OrthLoss and NcLoss in the second half stage of training procedures. This result demonstrates the effectiveness of our proposed feature separation loss. In addition to the OE approach, we also compare our method with other advanced works, including the classical work that studies data sampling strategies (POEM, []) and the adversarial feature augmentation work that aims to mitigate the impact of OOD distribution discrepancy (DAL, []). It is worth noticing that our method does not employ any data augmentation or selection algorithms, while we exhibit superior performances on CIFAR benchmarks. On CIFAR100, our method outperforms the best baseline DAL by $2.00\%$ on FPR95 and $1.18\%$ on AUROC. Based on the outstanding performance of our method, we suggest that our feature separation loss can be used as a basic training function like OE loss [] considering its simplicity.

**Table 1: Results on CIFAR10 and CIFAR100 benchmarks. The best result is in bold.**
| Method | SVHN | LSUN | iSUN | Textures | Places365 | Average |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ |  |
| CIFAR-10 |  |  |  |  |  |  |  |  |  |  |  |  |
| With vanilla training |  |  |  |  |  |  |  |  |  |  |  |  |
| MSP[] | 44.22 | 93.61 | 27.56 | 96.12 | 69.62 | 85.29 | 60.02 | 88.53 | 65.68 | 86.25 | 53.42 | 89.96 |
| Energy[] | 31.81 | 94.65 | 4.6 | 98.96 | 50.06 | 89.75 | 49.68 | 90.09 | 42.28 | 90.82 | 35.69 | 92.854 |
| Maha[] | 42.67 | 90.71 | 18.96 | 96.46 | 28.86 | 93.76 | 26.22 | 92.81 | 86.78 | 69.14 | 40.70 | 88.58 |
| KNN[] | 44.76 | 92.55 | 27.38 | 95.34 | 43.84 | 91.24 | 37.64 | 92.82 | 49.23 | 87.89 | 40.57 | 91.97 |
| With contrastive learning |  |  |  |  |  |  |  |  |  |  |  |  |
| CSI^∗[] | 17.37 | 97.69 | 6.75 | 98.46 | 12.58 | 97.95 | 25.65 | 94.70 | 40.00 | 92.05 | 20.47 | 96.17 |
| CIDER[] | 6.76 | 98.44 | 7.45 | 98.76 | 26.03 | 95.93 | 22.85 | 95.75 | 43.70 | 91.94 | 21.36 | 96.16 |
| KNN+^∗[] | 3.28 | 99.33 | 2.24 | 98.90 | 17.85 | 97.65 | 10.87 | 97.92 | 30.63 | 94.98 | 12.97 | 97.32 |
| With auxiliary OOD data |  |  |  |  |  |  |  |  |  |  |  |  |
| OE[] | 1.40 | 99.54 | 0.85 | 99.64 | 2.20 | 99.26 | 2.80 | 99.26 | 9.55 | 97.39 | 3.36 | 99.02 |
| Energy-OE[] | 0.75 | 99.50 | 0.90 | 98.98 | 1.50 | 99.22 | 2.75 | 98.92 | 9.05 | 97.33 | 2.99 | 98.79 |
| POEM[] | 25.66 | 95.43 | 94.97 | 76.44 | 1.58 | 99.64 | 20.62 | 95.73 | 53.39 | 88.38 | 39.24 | 91.10 |
| DAL[] | 0.75 | 99.28 | 0.75 | 99.62 | 0.70 | 99.33 | 2.35 | 98.99 | 8.90 | 97.10 | 2.69 | 98.86 |
| Ours | 0.40 | 99.28 | 0.60 | 99.68 | 1.60 | 99.25 | 2.45 | 98.83 | 7.40 | 97.60 | 2.49 | 98.93 |
| CIFAR-100 |  |  |  |  |  |  |  |  |  |  |  |  |
| With vanilla training |  |  |  |  |  |  |  |  |  |  |  |  |
| MSP[] | 74.79 | 79.64 | 54.72 | 86.46 | 93.85 | 56.92 | 88.76 | 68.48 | 83.24 | 71.95 | 79.07 | 72.69 |
| Energy[] | 70.18 | 87.15 | 17.15 | 97.05 | 91.37 | 65.50 | 84.77 | 76.72 | 78.91 | 75.77 | 62.75 | 80.44 |
| Maha[] | 77.73 | 78.01 | 98.46 | 63.44 | 47.74 | 88.76 | 54.93 | 82.53 | 97.22 | 54.11 | 75.22 | 73.37 |
| KNN[] | 71.86 | 83.31 | 78.89 | 70.09 | 79.60 | 70.86 | 72.89 | 80.05 | 80.91 | 71.33 | 76.83 | 75.13 |
| With contrastive learning |  |  |  |  |  |  |  |  |  |  |  |  |
| CSI^∗[] | 64.50 | 84.62 | 25.88 | 95.93 | 70.62 | 80.83 | 61.50 | 86.74 | 83.08 | 77.11 | 61.12 | 95.05 |
| CIDER[] | 16.47 | 96.23 | 45.45 | 81.64 | 66.01 | 82.21 | 49.79 | 87.48 | 82.66 | 68.39 | 52.08 | 83.19 |
| KNN+^∗[] | 32.50 | 93.86 | 47.41 | 84.93 | 39.82 | 91.12 | 43.05 | 88.55 | 63.26 | 79.28 | 45.20 | 87.55 |
| With auxiliary OOD data |  |  |  |  |  |  |  |  |  |  |  |  |
| OE[] | 38.70 | 92.90 | 18.30 | 96.67 | 36.35 | 92.59 | 43.05 | 91.00 | 52.45 | 87.86 | 37.77 | 92.21 |
| Energy-OE[] | 17.75 | 96.94 | 34.00 | 94.82 | 60.75 | 87.32 | 45.70 | 90.09 | 53.50 | 89.08 | 42.34 | 91.65 |
| POEM[] | 45.41 | 90.70 | 3.01 | 99.24 | 18.60 | 95.79 | 51.37 | 83.85 | 84.13 | 73.93 | 40.5 | 88.87 |
| DAL[] | 16.45 | 96.10 | 17.00 | 96.52 | 36.95 | 90.88 | 38.40 | 91.72 | 48.55 | 88.91 | 31.47 | 92.82 |
| Ours | 17.95 | 96.52 | 12.50 | 97.64 | 27.00 | 93.85 | 41.70 | 91.37 | 48.20 | 90.64 | 29.47 | 94.00 |

### 4.2 Hard OOD Detection

In addition to testing on the regular OOD datasets, we further consider three hard OOD datasets proposed in [], which are considered more difficult to distinguish from ID samples. Following the same setting in [, , ], we evaluate our detection performance on LSUN-Fix [], ImageNet-Resize [] and CIFAR100 [] with CIFAR10 as the ID dataset. Specific results are shown in Table 2. As we can see, our method shows comparable performance with DAL [] over three hard OOD datasets, outperforming the baseline OE method by $2.55\%$ on FPR95 on the ImageNet-Resize dataset.

**Table 2: Hard OOD detection on CIFAR10 benchmark.**
| Methods | LSUN-Fix | ImageNet-Resize | CIFAR-100 |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ |  |
| With contrastive learning |  |  |  |  |  |  |
| CSI^∗ | 39.79 | 93.63 | 37.47 | 93.93 | 45.64 | 87.64 |
| CIDER | 8.98 | 98.56 | 43.45 | 93.82 | 55.84 | 90.0 |
| KNN+^∗ | 24.88 | 95.75 | 30.52 | 94.85 | 40.00 | 89.11 |
| With auxiliary OOD data |  |  |  |  |  |  |
| OE[] | 1.00 | 99.53 | 7.20 | 98.48 | 25.05 | 94.86 |
| DAL[] | 0.65 | 99.59 | 3.75 | 98.63 | 26.00 | 94.35 |
| Ours | 0.75 | 99.07 | 4.65 | 98.42 | 24.60 | 94.69 |

### 4.3 Ablation Study

In this section, we conduct an ablation study to demonstrate the effectiveness of our proposed feature separation loss.

Choice of Training Loss. Based on Eq.5, our objective loss function contains four parts: the first one is to ensure the accuracy on ID data, and the rest three losses are to promote ID-OOD discrepancy. To study their respective contribution to the detection performance, we adopt different settings of the training loss to fine-tune our model and report their corresponding average FPR95 and AUROC over five considered OOD datasets. The result is shown in Table 3. From it, we can discover that the addition of $L_{Orth}$ can greatly improve the detection performance, and using $L_{OE}$, $L_{NC}$ and $L_{Orth}$ together achieves the best performance.

**Table 3: Performance of our method under different training loss settings.**
| Method | $L_{OE}$ | $L_{NC}$ | $L_{Orth}$ | CIFAR10 | CIFAR100 |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ |  |  |  |  |
| OE [] | ✓ | ✗ | ✗ | 3.36 | 99.02 | 37.77 | 92.21 |
| Ours-v1 | ✗ | ✓ | ✓ | 3.11 | 98.55 | 32.58 | 93.07 |
| Ours-v2 | ✓ | ✓ | ✗ | 3.62 | 98.96 | 39.91 | 91.22 |
| Ours-v3 | ✓ | ✗ | ✓ | 2.65 | 99.00 | 33.30 | 93.42 |
| Ours | ✓ | ✓ | ✓ | 2.49 | 98.93 | 29.47 | 94.00 |

Cosine Similarity vs. Euclidean Distance.
Based on the NC property of ID features, an intuitive idea is to maximize the Euclidean distance between OOD features and weights of the last FC layer. In this part, we compare this Euclidean distance with our proposed OrthLoss which presents the cosine similarity actually. Since maximizing the Euclidean distance will cause its value to approach infinity, we instead use $\frac{1}{\|z-w_{i}\|}$ for OOD features and $\|z_{ID}-w_{y}\|$ for ID features as the training loss in the Euclidean distance setting, and then minimizing this loss to fine-tune the model. The comparison results are presented in Table 4, where the cosine similarity loss significantly outperforms Euclidean distance loss. The underlying reason may be that our OrthLoss utilizes new dimensions to separate ID and OOD features. When faced with unseen OOD data, the feature variations tend to fall on the new dimension, resulting in minimal changes in the output.

**Table 4: Comparison between using the Euclidean distance and cosine similarity (ours) as the training loss to separate ID-OOD features.**
| Method | SVHN | LSUN | iSUN | Textures | Places365 | Average |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ |  |
| CIFAR-10 |  |  |  |  |  |  |  |  |  |  |  |  |
| Euclidean | 1.70 | 99.48 | 1.15 | 99.60 | 3.20 | 99.22 | 4.55 | 98.95 | 12.55 | 95.97 | 4.63 | 98.64 |
| Ours | 0.40 | 99.28 | 0.60 | 99.68 | 1.60 | 99.25 | 2.45 | 98.83 | 7.40 | 97.60 | 2.49 | 98.93 |
| CIFAR-100 |  |  |  |  |  |  |  |  |  |  |  |  |
| Euclidean | 51.95 | 85.97 | 19.95 | 96.13 | 42.35 | 87.45 | 44.80 | 88.18 | 56.95 | 85.29 | 43.20 | 88.60 |
| Ours | 17.95 | 96.52 | 12.50 | 97.64 | 27.00 | 93.85 | 41.70 | 91.37 | 48.20 | 90.64 | 29.47 | 94.00 |

### 4.4 Discussion

Fluctuation in Detection Performance.
We have observed considerable fluctuations in the performance of the DAL method [] under repeated experiments with identical settings. Therefore, we evaluate the mean and variance of performance after repeating the same experiment five times. The results, shown in Table 5, indicate that our approach exhibits greater stability, particularly on the CIFAR100 benchmark. Notably, even the OE method shows the FPR95 variance of $1.137$ on CIFAR100, whereas our method maintains a variance of only $0.027$.

**Table 5: Fluctuation in detection performance of different methods.**
| Method | CIFAR10 | CIFAR100 |  |  |
| --- | --- | --- | --- | --- |
| FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ |  |
| OE [] | 3.22±0.0017 | 99.07±0.0014 | 36.29±1.137 | 92.31±0.013 |
| DAL [] | 2.87±0.0234 | 98.82±0.0027 | 30.44±2.216 | 93.07±0.075 |
| Ours | 2.49±0.0007 | 98.92±0.0033 | 29.50±0.027 | 93.98±0.014 |

Different Score Function.
Since we use our proposed score function in Eq 7 to detect OOD samples while other auxiliary OOD data based methods only employ MSP score [], in this part, we also evaluate our model with MSP score for a fair comparison. The results in Table 6 demonstrate that our approach also achieves commendable performance under the MSP score, with only a slight decline compared to using the proposed score function.

**Table 6: Performance of adopting different score functions in our method.**
| Method | Score Function | CIFAR10 | CIFAR100 |  |  |
| --- | --- | --- | --- | --- | --- |
| FPR95$\downarrow$ | AUROC$\uparrow$ | FPR95$\downarrow$ | AUROC$\uparrow$ |  |  |
| Ours | MSP | 2.77 | 98.76 | 29.96 | 93.27 |
| Eq. 7 | 2.49 | 98.93 | 29.47 | 94.00 |  |

Feature Separation Degree.
In this part, we evaluate the degree of feature separation between ID and OOD data to validate the effectiveness of our proposed loss. Leveraging the NC property of ID features, we use the FC weight as the intermediary to design our measurement standards. Specifically, we propose three metrics, respectively defined by the Euclidean distance and cosine similarity between features and the weight of the predicted class, and the reconstruction error to the subspace spanned by FC weights. The results are shown in Table 7, where OOD means unseen test OOD data instead of auxiliary OOD samples. It can be seen that our model presents higher differences under the three metrics compared to vanilla and OE-trained models.

**Table 7: Feature separation degree of different methods measured by three metrics. The higher difference (Diff) means better discrepancy between ID and OOD features.**
| Method | Euclidean Distance | Cosine Similarity | Reconstruction Error |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| ID | OOD | Diff$\uparrow$ | ID | OOD | Diff$\uparrow$ | ID | OOD | Diff$\uparrow$ |  |
| Vanilla | 0.80 | 1.12 | 0.32 | 0.69 | 0.47 | 0.22 | 0.19 | 0.32 | 0.13 |
| OE | 0.86 | 1.21 | 0.35 | 0.79 | 0.32 | 0.47 | 0.41 | 0.83 | 0.42 |
| Ours | 0.69 | 1.16 | 0.47 | 0.75 | $3e^{-5}$ | 0.75 | 0.43 | 0.86 | 0.43 |

## 5 Conclusion

In this paper, we propose a novel training loss designed to enhance the feature discrepancy between ID and OOD data during model fine-tuning with auxiliary OOD datasets. Given the inherent diversity and complexity of OOD sample distributions, we leverage the Neural Collapse property of ID features, which indicates that the penultimate features of ID samples within a class are nearly identical to the last layer weight of the corresponding class. Utilizing this property, we introduce a separation loss that confines OOD features to dimensions that are orthogonal to the principal subspace of ID features formed by NC. Our extensive experiments validate the effectiveness of our feature separation loss, achieving SOTA performance on CIFAR benchmarks. We believe that our study will inspire further research into pursuing feature discrepancy when employing auxiliary OOD data for model fine-tuning in OOD detection.

## Appendix A Appendix / supplemental material

### A.1 Limitations

Our approach requires an auxiliary OOD dataset and a fine-tuning process. But for real-world applications, it is more practical to detect directly based on a pre-trained model. This is a general limitation for auxiliary OOD data based approaches. A possible solution is to use auxiliary OOD data during the test phase by designing test-time adaptation algorithms [, , ], thereby obviating the training process but maintaining outstanding detection performance.

## Peer Reviews

confidence: 2
contribution: 2
initial_rating: 5
presentation: 3
questions: Please check questions alongside the weaknesses.
soundness: 3
strengths: - The paper is well-motivated in its use of Neural Collapse (NC) to improve OOD detection, effectively highlighting NC’s natural feature clustering property as a robust basis for separating ID and OOD data. 
- The incorporation of Neural Collapse as a theoretical foundation adds substantial depth to the methodology, offering a compelling explanation for the effectiveness of feature-level separation in enhancing OOD detection. 
- The proposed approach is conceptually straightforward and easy to implement.
summary: The paper proposes an OOD detection approach that enhances feature separation. The proposed method is based on Neural Collapse (NC), which suggests that features of ID samples collapse to similar values within a class. Motivated by NC, the authors introduce Separation Loss to encourage OOD features to occupy subspaces orthogonal to the principal subspace of ID features, effectively separating ID and OOD samples at the feature level.
weaknesses: - In Section 3.4, the paper discusses two alternative training strategies: one that directly incorporates all loss terms and another that initially trains with cross-entropy (CE) loss before introducing the proposed losses. However, guidance on when to choose between these strategies in general cases is lacking. Additional discussion on how this choice could affect the model’s performance or usability would be beneficial.
- The proposed method mainly includes two loss terms, i.e., the Sep loss and Clu loss, upon the OE loss. As discussed in the paper (e.g., the abstract), the Sep loss reflects the main motivation of neural collapse (NC). The ablation studies in Table 5 show that these two terms perform with different significances. The behaviours and importance of these two loss teams are unclear. 
- Although the proposed method performs well on ImageNet-1k (Table 1), its performance is less consistent on other benchmarks, as seen in Table 2 and particularly Table 3, where broader comparisons are provided. Further explanation or analysis regarding this variability would be valuable to understand the method’s limitations. 
- More analysis of the learned representation space, such as visualizations of the embedding space, would provide insight into how well the method achieves feature separation and could strengthen the evaluation of its effectiveness.

---

confidence: 4
contribution: 2
initial_rating: 6
presentation: 3
questions: - The proposed method shares fundamental similarities with KNN, as both approaches classify data based on distance calculations in feature space, identifying ID data through closer distances and OOD data through farther distances. Could the authors elaborate on the key distinctions between their method and the KNN approach?
- Given the use of Wide ResNet-40-2 architecture for CIFAR-10 and CIFAR-100 datasets, does the method have specific requirements regarding network feature dimensions? A detailed analysis of this aspect would be valuable.
soundness: 3
strengths: The motivation behind this method is reasonable and worth exploring.
summary: The paper proposes a novel strategy for out-of-distribution detection. The approach is based on Neural Collapse and employs this property to avoid modeling OOD feature distributions while effectively segregating ID and OOD features.
weaknesses: - While Figure 2 demonstrates the distribution changes of the OOD training set during training, which is expected, it would be more insightful to see the distribution patterns of OOD data during the testing phase.
- The improvement in AUROC metrics compared to existing methods is relatively modest.
- Although the authors claim to follow DAL's experimental setup on ImageNet (lines 321, 332), there are discrepancies between the metrics reported in Table 1 (lines 374, 375) and those in Table 16 of the DAL paper ("Learning to Augment Distributions for Out-of-Distribution Detection").
- The experimental comparison on ImageNet is limited to only two methods, whereas the DAL paper compared five methods in their Table 16, suggesting insufficient comparative analysis.

p.s. There appears to be an inconsistency in decimal places for the average AUROC of Energy between lines 381 and 382.

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 4
questions: 1. The improvements on the ImageNet benchmark are relatively marginal compared to the CIFAR benchmarks. Could you provide a more detailed discussion to clarify the potential reasons for this difference?

2. As noted in line 469, `When faced with unseen OOD data, the feature variations tend to fall on the new dimension, resulting in minimal changes on the output.` Would these orthogonal dimensions become exhausted when dealing with a large-scale ID dataset? Additional justification on this point would be helpful, no further empirical results are needed.

3. In Table 9, the calculation relies on FC weights, which aligns with the paper’s motivation since the optimization is specifically designed to achieve these results. Would using empirical class mean features instead of FC weights yield different outcomes? This approach could also further align with the NC motivation, given that the penultimate features of ID samples within a class are nearly identical to the last layer weights.
soundness: 3
strengths: 1. The paper introduces a separation loss based on the Neural Collapse phenomenon to enhance feature-space disparity between ID and OOD samples. This approach builds on strong analytical foundations from NC, addressing key challenges specific to OOD detection.

2. The experiments are comprehensive, covering multiple datasets and architectures, with ablation studies that effectively address most concerns.

3. The proposed method is straightforward and clear. The proposed method is broadly applicable to any OOD detection method based on Outlier Exposure.
summary: This paper focuses on feature-space separation rather than output-space discrepancies. The authors propose a novel approach leveraging Neural Collapse, which describes how ID samples’ penultimate features converge near their respective class weights. The core contribution is the Separation Loss, which aligns OOD features orthogonally to ID feature subspaces. Extensive experiments across standard benchmarks demonstrate that the proposed method achieves state-of-the-art performance in OOD detection.
weaknesses: I hope the authors could address my questions as follows.

---

confidence: 5
contribution: 3
initial_rating: 8
presentation: 4
questions: 1- I would suggest testing your method using OpenOOD framework[1], as you can test Near vs Far OOD beside testing transformer based architectures.

2- The manuscript discusses the application of your method under the assumption of the Neural Collapse (NC) property. However, it is not clear how these methods might perform in scenarios where NC does not hold, such as in imbalanced datasets[2]. Could the authors investigate and elaborate on the potential impact on the results if the NC property is weakened or absent due to dataset characteristics like imbalance? Additionally, I recommend including experiments with imbalanced datasets to provide empirical evidence of the method's robustness under these conditions. This would enhance the paper's contribution by addressing the generalizability of the NC phenomenon across different data distributions.


Bibliography:

1. Zhang J, Yang J, Wang P, Wang H, Lin Y, Zhang H, Sun Y, Du X, Zhou K, Zhang W, Li Y. Openood v1. 5: Enhanced benchmark for out-of-distribution detection. arXiv preprint arXiv:2306.09301. 2023 Jun 15.

2. Zhang E, Li C, Geng C, Chen S. All-around Neural Collapse for Imbalanced Classification. arXiv preprint arXiv:2408.07253. 2024 Aug 14.
soundness: 4
strengths: - The concept of applying the NC phenomenon to directly manipulate feature spaces for OOD detection is innovative. Unlike traditional methods that focus on output discrepancies, this paper focuses on feature separability, which is a fresh perspective in the field.

- The empirical validation is robust, covering several benchmarks and comparing against a comprehensive suite of methods. The novel loss function, grounded in theoretical insights from NC, is shown to effectively enhance feature separation.

- The paper is well-organized and articulately written, with clear explanations of the NC phenomenon, the motivation for the new loss function, and the experimental setup. The visualizations effectively illustrate how feature separation is achieved, aiding in understanding.

- The approach addresses a critical gap in OOD detection by improving model reliability in real-world applications, where ID and OOD data may not be clearly distinguishable through outputs alone. This has significant implications for deploying DNNs in safety-critical domains.
summary: The paper introduces a novel approach for enhancing out-of-distribution (OOD) detection in deep neural networks (DNNs) by improving outlier exposure training. This approach leverages the Neural Collapse (NC) phenomenon where features within each class collapse to a point forming an ETF simplex with other classes to improve the separability of in-distribution (ID) and OOD data. The authors propose a new loss function, "Separation Loss," designed to maximize the orthogonality between the feature representations of ID and OOD data. The orthogonality is maximized by minimizing the cosine similarity with the last layer FC layer weights for OOD data and by aligning the representation of ID data with the predicted class weight from the last layer. This method achieves state-of-the-art (SOTA) performance on CIFAR10, CIFAR100, and ImageNet benchmarks without requiring additional data augmentation or sampling techniques.
weaknesses: Dependency on NC Property: The effectiveness of the method is heavily dependent on the presence of the NC phenomenon, which may not occur in all network architectures or training configurations. (The NC property usually fail on the testing set [1])

The authors claim that their method works well across different architectures while only testing ResNet and WideResnet and DenseNet. It would be more valuable to test your method against transformer based architecture like ViT or Swin as their features differ due to the global attention mechanism and patch based representations. This experiment will validate the method’s generalizability to different architectures.

In table 2, categorizing the OOD datasets into Near and Far OOD would provide useful insight in the performance of the separation loss, as it might be working on Far-OOD better than Near-OOD which are more entangled in the representation space.

Bibliography:
1. Hui L, Belkin M, Nakkiran P. arXiv.org. 2022 [cited 2023 Dec 10]. Limitations of Neural Collapse for Understanding Generalization in Deep Learning. Available from: https://arxiv.org/abs/2202.08384v1

Meta-review: The authors propose to include two additional terms to standard OE (outlier exposure) loss function for improved out of distribution (OOD) detection-- the first term is to ensure extremely compact clustering of in-distribution samples while the second one ensures that the OOD features lie on the subspace orthogonal to the subspace spanned by the features (weight vectors) of ID classes. This new loss has been shown to perform better in OOD detection tasks over several benchmarks. 

The approach seems to be simple and intuitive, and the results are promising. I found the dependency of the new loss function on too many hyper-parameters a bit concerning however the authors showed that the method is not much sensitive to the choice of hyper-parameter.

I initially considered this work to be a borderline but I must admit that the comprehensive responses from the authors to the extremely relevant questions by the reviewers did not only convince most of the reviewers but also to me that this work would be a good fit to ICLR. However, the authors must incorporate all the comments by the reviewers in their revised draft. They all make sense and will surely increase the visibility of this work.

Decision: Accept (Poster)