Title: Optimal Parameter and Neuron Pruning for Out-of-Distribution Detection
Venue: NeurIPS 2023
Accepted: yes
Keywords: Out-of-Distribution Detection

Parameter Sensitivity

Parameter Pruning

Neuron Pruning
Abstract: For a machine learning model deployed in real world scenarios, the ability of detecting out-of-distribution (OOD) samples is indispensable and challenging. Most existing OOD detection methods focused on exploring advanced training skills or training-free tricks to prevent the model from yielding overconfident confidence score for unknown samples. The training-based methods require expensive training cost and rely on OOD samples which are not always available, while most training-free methods can not efficiently utilize the prior information from the training data. In this work, we propose an \textbf{O}ptimal \textbf{P}arameter and \textbf{N}euron \textbf{P}runing (\textbf{OPNP}) approach, which aims to identify and remove those parameters and neurons that lead to over-fitting. The main method is divided into two steps. In the first step, we evaluate the sensitivity of the model parameters and neurons by averaging gradients over all training samples. In the second step, the parameters and neurons with exceptionally large or close to zero sensitivities are removed for prediction. Our proposal is training-free, compatible with other post-hoc methods, and exploring the information from all training data. Extensive experiments are performed on multiple OOD detection tasks and model architectures, showing that our proposed OPNP consistently outperforms the existing methods by a large margin.

Optimal Parameter and Neuron Pruning for Out-of-Distribution Detection

Abstract

For a machine learning model deployed in real world scenarios, the ability of detecting out-of-distribution (OOD) samples is indispensable and challenging. Most existing OOD detection methods focused on exploring advanced training skills or training-free tricks to prevent the model from yielding overconfident confidence score for unknown samples. The training-based methods require expensive training cost and rely on OOD samples which are not always available, while most trainingfree methods can not efficiently utilize the prior information from the training data. In this work, we propose an O ptimal P arameter and N euron P runing ( OPNP ) approach, which aims to identify and remove those parameters and neurons that lead to over-fitting. The main method is divided into two steps. In the first step, we evaluate the sensitivity of the model parameters and neurons by averaging gradients over all training samples. In the second step, the parameters and neurons with exceptionally large or close to zero sensitivities are removed for prediction. Our proposal is training-free, compatible with other post-hoc methods, and exploring the information from all training data. Extensive experiments are performed on multiple OOD detection tasks and model architectures, showing that our proposed OPNP consistently outperforms the existing methods by a large margin.

1 Introduction

Over the past decade, deep neural networks have achieved dramatic performance gains in computer vision [7], natural language processing [38], and AI for Science [25]. However, when deploying those deep learning models in real world scenarios, the model will provide a false prediction result for unseen categories, which will lead to serious security issues. A promising approach to address this problem is Out-of-Distribution (OOD) detection [51], which aims to distinguish whether the given sample is from training class or unknown category. The deep learning models with good OOD detection ability know what they don't know and can be used safely in real world applications.

Recently, a large number of works have been proposed to address the OOD detection problem [22, 21, 26]. Early representative methods utilized the Maximum Softmax Probability (MSP) [21] or Mahalanobis distance [26] as score function. The main challenge is that modern overparameterized deep neural networks can easily produce overconfident predictions on OOD samples, making the in-distribution (ID) data and OOD data inseparable. To alleviate the overconfident problem, some training-based methods and post-hoc methods have been proposed. The training-based methods mitigate the overconfident problem by incorporating OOD samples in training process [22] or synthesizing virtual outliers to regularize the model's decision boundary [9]. The post-hoc methods mainly focused on optimizing score function [24, 29, 31], or rectifying activations [43, 6] to make the ID and OOD samples more separable. The training-based methods are controllable and interpretable, but they rely on expensive training cost and additional OOD samples, which are not always available.

0.0

0.2

0.4

0.6

0.8

1.0

Normalized parameter sensitivity

0.0

2.5

5.0

7.5

10.0

12.5

15.0

17.5

Density

avg=0.063

Parameter sensitivity distribution of ResNet50

(a) ResNet50

0.0

0.2

0.4

0.6

0.8

1.0

Normalized parameter sensitivity

0

10

20

30

40

Density

avg=0.052

Parameter sensitivity distribution of ViT-B/16

(b) ViT-B/16

In contrast, the post-hoc methods are training-free, low-cost and plug and play, however they can not effectively leverage the prior information from the training data and trained models.

It has been widely observed that overparameterized deep neural networks often suffer from redundant parameters and neurons, which consequently result in overconfident predictions. Conversely, a precisely pruned sub-network is capable of achieving comparable performance [13, 17, 5, 30, 46]. This motivates a straightforward question: Can we identify the parameters and neurons that lead to overconfident outputs by leveraging the prior information from the off-the-shelf models and training samples ? To answer this question, we first demonstrate the parameter sensitivity of the last fullyconnected (FC) layer for ResNet50 [18] and Vision Transformer (ViT-B/16) [7] in Fig. 1. As can be observed, the distribution of parameter sensitivity is heavily positively skewed. More specifically, a significant proportion of parameter sensitivities are close to zero, while only a few parameters exhibit exceptionally high sensitivities. The gap between the maximum and minimum sensitivity values is more than 200 times.

The above observation naturally inspires a simple yet surprisingly effective method O ptimal P arameter and N euron P runing ( OPNP ) for OOD detection. The motivations of our OPNP are in two aspects: (1) The parameters and neurons with sensitivities close to zero are redundant and can lead to overconfident predictions [23, 15, 44]. (2) The parameters with exceptionally large sensitivity result in a sharp landscape, which hurts the model generalization [11, 55, 54]. Therefore, in this study, we present empirical and theoretical evidences to show that the OOD detection performance can be significantly improved by pruning parameters and neurons with exceptionally large or close to zero sensitivities. The main contribution of this paper are as follows:

A gradient based approach is present to estimate the sensitivity of parameters and neurons in deep model. Building upon this approach, we introduce OPNP - A simple yet effective training-free method, which significantly improves OOD detection performance by removing weights and neurons with exceptionally large or close to zero sensitivities.

We evaluate OPNP on different OOD detection tasks and model architectures, including ResNet and ViT. Compared to the baseline model, OPNP achieves 32.5% FPR95 reduction on a large-scale ImageNet-1k benchmark, and outperforms existing state-of-the-art post-hoc OOD detection method by 5.5% in FPR95.

Extensive ablation experiments are performed to reveal the insight and effectiveness of the proposed method. We show that OPNP is compatible with other post-hoc methods and can benefit model calibration. We believe our insights can inspire and accelerate future research in related tasks.

2 Related Work

General OOD Detection. OOD detection is highly relevant to several early research tasks, including outlier detection (OD), anomaly detection (AD) [40] and open-set recognition (OSR) [14]. All

these tasks are aim to identifying the OOD samples in the open world scenario [51]. The most promising OOD detection methods can be divided into five categories, including density-based methods [39], distance-based methods [26, 45], outlier exposure methods [22, 28, 2], virtual OOD synthesis methods [9, 47], and post-hoc methods [31, 43]. Besides, some recent advances also pay attention to exploring large-scale pretrained vision-language model for OOD detection [35, 10], and extending OOD detection from classification to other learning tasks, such as object detection [8] and segmentation [20]. In this study, we mainly focus on post-hoc OOD detection, which is a training-free approach that does not require any OOD samples. For a more comprehensive understanding of the general OOD detection task, we suggest referring to [51] for further details.

Post-hoc OOD Detection. Recently, the post-hoc OOD detection methods have achieved promising performance and drawn increasing attention [44, 43, 57, 31, 29]. To alleviate the over-confident prediction caused by the softmax function, ODIN [29] introduces a temperature scaling strategy to make the softmax scores between ID and OOD images more separable. Liu et al. [31] replace the MSP score with energy score, which is theoretically aligned with the probability density and less susceptible to the overconfident problem. In huang et. al [24], GradNorm is presented which utilizes the magnitude of gradients as OOD score. Another line of work relieve overconfident problem by rectifying typical features in the penultimate layer [43, 6, 57]. In particular, ReAct [43] truncates features with a global threshold, which is chosen to preserve the activations for ID data while rectifying that of OOD data. ASH [6] shows that simply removing lower activations or binarizing representations leads to promising OOD detection performance. The most relevant method to our proposal is DICE [44], which ranks weights based on a measure of contribution, and selectively use the most salient weights to derive the output for OOD detection. Both DICE and our proposal alleviate over-fitting by model pruning. DICE selects the most important connections while our proposal removes the most sensitive and insensitive parameters and neurons. Besides, the method used to measure the weight importance or sensitivity is different.

Parameter and Neuron Pruning. In deep neural networks, parameter and neuron pruning is widely used for reducing over-fitting [23, 42, 15, 5] and model compression [33, 17, 27] . Dropout is the most well-known method to improve the robustness of deep models, which randomly drops some neurons [42] or connections [48] in training time. Based on dropout, Gomez et al. [15] introduce targeted dropout, which drops units and weights with low magnitude. They experimentally demonstrated that target dropout benefit to post-hoc pruning of units and weights. Besides, parameter and neuron pruning have also been widely used in model compression. Han et al. [17] indicate that the weights with low magnitude is less important and propose to remove those weights for model compression. In contrast, Li et al. [27] propose to drop the feature maps based on weight norms, the model performance is well preserved after pruning more than 30% units. In [30, 3], the authors demonstrate the effectiveness of ensembling multiple sparse networks, which are trained from scratch with dynamic sparsity constraint, for OOD detection. The aforementioned researches have demonstrated that the weights and neurons are significantly redundant in deep networks, which inspires us to prune the parameters and neurons that result in over-fitting for OOD detection. We believe optimal post-hoc parameter and neuron pruning is a promising approach for OOD detection.

3 Method

3.1 Problem statement

Assume that we have an in-distribution dataset D in of pairs ( x in , y in ) and an out-of-distribution dataset D out of pairs ( x out , y out ) , where x in , x out ∈ X denote the input feature vector of ID and OOD samples, y in ∈ Y in := { 1 , 2 , · · · , K } denotes the ID class label, and y out ∈ Y out denotes the output class label, Y in ∩ Y out = ∅ . Given a classification model f ( x ; θ ) trained from in-distribution dataset D in . The goal of post-hoc OOD detection is to design a binary classifier g λ ( x ) which is able to distinguish whether the test sample is from ID or OOD distribution. Therefore, the challenge of OOD detection is to find an optimal score function S ( x ) such that for a given test sample x ∈ X ,

where samples with higher score S ( x ) are classified as ID and vice versa, λ is the threshold which usually set to ensure 95% ID samples are correctly classified. Maximum softmax probability [21]

and energy score [31] are the most widely used score functions in post-hoc OOD detection. We follow previous post-hoc methods [43, 44] to utilize energy score as OOD detection metric, which consistently outperforms MSP score.

We denote h ( x ) ∈ R L the feature representation from the penultimate layer, denote W ∈ R L × K and b ∈ R K the output weights and bias of the last FC layer. Then, the output logit can be given as

The energy score function [31] maps the output logit to a energy value by,

where f i ( x ) denotes the logit output for class i . The energy score reduces over-fitting caused by softmax function, but the overparameterized connection weights W in the last fully-connected layer may still cause overconfident logit output. Therefore, in the following section, we aim to provide an optimal parameter and neuron pruning strategy to reduce over-fitting.

3.2 Parameter sensitivity estimation

In this section, we propose to estimate parameter sensitivity by measuring how sensitive the output energy score to a small change of parameters. For a given sample x k and corresponding energy output E ( x k ; θ ) , a small change δ ij is added to the parameter θ ij , which results in a change in the output energy score,

Here, g ij ( x k ) denotes the gradient of model output to the parameter θ ij at data point x k . Since δ ij is a small constant, the parameter sensitivity to model output can be measured by the magnitude of the gradient g ij . In this respect, given a batch of samples { x k } m k =1 , the parameter sensitivity can be estimated by accumulating the gradients over all input samples,

where M ij denotes the sensitivity of parameter θ ij . It's worth noting that we utilize the change in energy score as the sensitivity measure, which is better aligned with the OOD detection metric. Practically, the parameter sensitivity can also be measured by other model output, such as the change of logit norm ∥ f ( x ; θ ) ∥ 2 , which has been exploited in lifelong learning [1].

In Fig. 1, we illustrate the sensitivity of parameter W for two representative deep networks ResNet50 [18] and ViT-B/16 [7], where the maximum sensitivity is normalized to 1. It can be seen that the maximum parameter sensitivity of the ResNet50 and ViT-B/16 is nearly 20 times than the average sensitivity. In addition, compared with ViT-B/16, there are more parameters with sensitivity close to zero in ResNet50, which indicates that the last FC layer of ResNet50 has more redundant parameters. Based on the intuition that the parameters and neurons with exceptionally large sensitivity or with sensitivity close to zero tend to result in overconfident prediction, an optimal parameter and neuron pruning strategy is introduced to improve the OOD detection performance.

3.3 Optimal parameter and neuron pruning

In this section, we mainly introduce how to prune the connection weights and neurons in the last fully-connected layer, which directly result in overconfident results. The pruning strategy in other layers can be achieved in the same manner.

ℎ(𝑥)

W 𝑓(𝑥;𝜃)

OPNP

𝑓(𝑥; 𝜃)

Before	OPNP

After	OPNP

)

ℎ(𝑥)

* W

Pruned Neuron

Pruned Parameter

(a) Optimal parameter and neuron pruning

Parameter sensitivity Distribution

Neuron sensitivity Distribution

Before	OPNP

After	OPNP

(b) Sensitivity distribution

Parameter Pruning. Given the connection weights W that maps the feature representation to logit, the corresponding parameter sensitivity M can be computed according to Eq. 6. As mentioned above, the parameters with exceptionally large or close to zero sensitivity tend to result in over-fitting. Therefore, a simple threshold function can be utilized to remove the risky connections,

where W ij denotes the weights after pruning, Ω w min and Ω w max denote the minimum and maximum thresholds. To align with previous post-hoc methods [43, 44, 6], we obtain the threshold by a percentile ρ , which indicates that the threshold is set to the ρ th-percentile of the entire sensitivity matrix. For example, ρ w max = 1% represents that Ω w max is set to the 1% largest sensitivity value in M , and ρ w min = 10% represents that Ω w min is set to the 10% smallest sensitivity value in M . In Fig. 2(b), the first row illustrates the sensitivity distribution of parameter W in ResNet50 before and after parameter pruning. After pruning, the connection weights that larger than Ω w max or smaller than Ω w min are removed, and will not contribute to the output logit, which reduces the risk of over-fitting.

Neuron Pruning. In additional to parameter pruning, we also propose to prune the neurons in the pre-logit layer, which has also been shown to mitigate over-fitting [42, 15]. For the i -th neuron in the pre-logit layer, it contributes to all output neurons, therefore the sensitivity of the i -th neuron should be defined based on the sensitivity of the connection weights between the i -th hidden neuron and all output neurons. Considering that the ℓ 1 or ℓ 2 norm of the weights are usually used to measure the importance of the units in deep networks [41, 15]. We define the neuron sensitivity as the average sensitivity of weights that connected with the neuron, which is equivalent to ℓ 1 norm of the weight sensitivity, and reflects the average sensitivity to all classes, i.e.,

where O i denotes the sensitivity of i -th neuron in pre-logit layer, K represents the number of output neurons. In this respect, we can use a similar threshold function as Eq. 7 to remove the risky neurons,

where h i ( x ) denotes the output feature from the i -th pruned neuron in the pre-logit layer, Ω o min and Ω o max represent the minimum and maximum sensitivity thresholds determined by the pruning percentage ρ o min and ρ o max . The second row in Fig. 2(b) illustrates the sensitivity distribution of the hidden neurons in ResNet50 before and after neuron pruning, where the maximum sensitivity is

normalized to 1. As observed, after neuron pruning, the redundant neurons (with sensitivity close to zero) and risky neurons (with sensitivity far above the average) are removed and the distribution of sensitivity across neurons becomes more uniform, which potentially reduces over-fitting.

3.4 Insight Justification

The following remarks are provided to explain why OPNP improves OOD detection performance.

Remark 1. Parameter and neuron pruning avoid overconfident predictions. The overparameterized deep neural networks tend to generate overconfident predictions even for OOD samples [19, 37, 16]. Therefore, most existing methods improve OOD performance by avoiding overconfident predictions [29, 31, 44]. For a deep network, the last fully connected layer can be regarded as a linear classifier. The most widely used technique to prevent a classifier from overfitting is to employ a ℓ 1 or ℓ 2 regularization, which can be formulated as min θ E ( x , y ) ∼ D ∥ θ ⊤ · h ( x ) -y ∥ 2 2 + λ R ( θ ) , where R ( θ ) represents ℓ 1 - or ℓ 2 -norm of θ . As the parameter pruning is able to reduce R ( θ ) , it can be regarded as an effective post regularization technique that reduces the model complexity and avoids overconfident predictions. Besides, the neuron pruning is similar to target dropout [15] which has also been demonstrated to reduce overfitting. Therefore, the proposed OPNP avoids overconfident predictions and potentially improves the OOD detection performance.

Remark 2. Pruning the least sensitive parameters and neurons improve separability between ID and OOD samples. We denote f j ( x ) the logit output of j -th class, after pruning the least sensitive parameters, the logit reduction of the j -th class can be estimated as

It shows that the logit reduction is positively correlated with the average sensitivity of the pruned weights. As the parameter sensitivity is computed over the training ID set, the least sensitive parameters on ID distribution should be more sensitive for OOD samples on average, i.e.,

Therefore, the logit reduction on OOD samples is larger than on ID samples ∆ f j ( x out ) > ∆ f j ( x in ) , which leads to better separability between ID and OOD samples, and improves OOD detection performance. We also show the parameter sensitivity distribution (on ID and OOD sets) of the pruned weights in Fig. 9, which experimentally verifies Eq. 11.

Remark 3. Pruning the most sensitive parameters and neurons improves generalization. We follow [54] to define the first-order flatness as

where ∆ f ( θ ′ ) denotes the derivative at point θ ′ , B ( θ , ρ ) = { θ ′ : ∥ θ -θ ′ ∥ < ρ } denotes the open ball of radius ρ centered at the point θ in the Euclidean space and ρ denotes the perturbation radius that controls the magnitude of the neighbourhood. The flatness R ρ ( θ ) describes how flat the function landscape is [54]. It has been demonstrated that a flatter landscape could lead to better generalization [11, 55, 54, 53]. Eq. 12 indicates that the first-order flatness is determined by the largest gradient, therefore, our proposed method pruning the most sensitive parameters is able to improve the flatness of the function landscape and lead to better generalization. However, according to Remark 2 , pruning the most sensitive parameters and neurons may also hurt the separability between ID and OOD samples. Therefore, there is a trade-off between better generalization and better ID-OOD separability. This explains why OOD performance improves with very few sensitive parameters pruned and drops with a large pruning ratio, as demonstrated in Fig. 3.

4 Experiments

In this section, we describe our experimental setup and implementation details, then evaluate the effectiveness of the proposed OPNP method in different model architectures and OOD detection benchmarks, followed by extensive ablation studies.

4.1 Experimental Setup

Datasets. Following prior works [43, 44], we utilize ImageNet-1K, CIFAR-10 and CIFAR-100 as ID dataset. For ImageNet-1K benchmark, 50000 test samples are used as test ID samples, and four datasets are used as test OOD data, which are from (subset of) iNaturalist, SUN, Place and Texture [44]. For CIFAR benchmark, the standard split with 50,000 training ID images and 10,000 test ID images are utilized for training and evaluation. We follow [43, 44] to evaluate on six common OOD datasets 2 , including iSUN [50], LSUN-Resize [52], LSUN-Crop [52], SVHN [36], Places365 [56], and Textures [4].

Models. We utilize two representative deep models, ResNet50 [18] and ViT-B/16 [7], to evaluate our proposal. For ResNet50, the model weights provided in TorchVision [34] is utilized. For ViT-B/16, we utilize the model weights provided in Pytorch Image Models (timm) library [49]. For both models, we only estimate the parameter and neuron sensitivity in the last fully-connected (FC) layer. The number of neurons in th pre-logit layer are 2048 and 768 for ResNet50 and ViT-B/16 respectively.

Evaluation Metric and Baselines. We utilize FPR95 and AUROC as evaluation metrics, which are the most important metrics in OOD detection [22, 31]. FPR95 is short for FPR@TPR95 which represents the false positive rate when the true positive rate is 95%. AUROC denotes the area under the receiver operating characteristic curve, which is threshold-free and reflects the average performance under different thresholds. Note that we following [44] do not report the ID classification accuracy since our proposal is training-free and only revises the last FC layer. We can always use the original FC layer for classification, which ensures an identical classification accuracy as unpruned model. We compared our OPNP with the most competitive post-hoc OOD detection methods, including MSP [21], ODIN[29], Mahalanobis distance [26], Energy Score [31], ReAct [43] and DICE [44].

Implementation Details. Implementation of this work is based on Pytorch library 3 . We use all training images in ImageNet-1K to obtain the parameter sensitivity by using the autograd function achieved by energy_score.backward() . At test time, all images are resized to 224 × 224 . The hyperparameters ρ w min , ρ w max , ρ o min , ρ o max are experimentally determined in the validation set, which includes 50000 test ID samples and 50000 test OOD samples that are selected from images21k. We utilize grid search to determine the optimal pruning percentage, where we vary ρ w min = { 0 , 5 , 10 , 20 , · · · , 60 } , ρ w max = { 0 , 0 . 1 , 0 . 3 , 0 . 5 , 1 , 3 , 5 } , ρ o min = { 0 , 5 , 10 , 20 , · · · , 50 } , ρ o max = { 0 , 0 . 5 , 1 , 5 , 10 , 20 , · · · , 50 } . The same hyperparameters are adopted in the same model.

4.2 Main Results.

Evaluation on ImageNet-1K benchmark. In Table 1, we compare our proposal with other competitive post-hoc OOD detection methods based on ResNet50. ↑ denotes larger values are better and ↓ denotes smaller values are better. The results for those comparison baselines are directly taken from

[43, 44], which utilizes the same experimental setup as ours. OPP, ONP and OPNP represent only utilize optimal parameter pruning, only utilize optimal neuron pruning and utilize both parameter and neuron pruning, respectively. The results in Table 1 reveal several interesting observations: (1) Optimal parameter pruning (OPP) achieves similar performance as DICE which also removes unimportant connections for OOD detection, and significantly outperforms MSP [21], Mahalanobis distance [26] and Energy [31] baselines. (2) Optimal neuron pruning (OPN) achieves much better performance than OPP, outperforms DICE [44] by a large margin and outperforms SOTA feature rectification method (ReAct) [43] by 2.1% in FPR95 and 0.7% in AUROC. (3) Compared to OPP and ONP, combining parameter pruning and neuron pruning (OPNP) also reduces FPR95 by 3.3% and improves AUROC by 0.6% based on ONP. (4) OPNP outperforms both SOTA weights pruning method (DICE) and SOTA feature rectification method (ReAct) by a large margin (more than 5% in FPR95). (5) Our proposed OPNP does not outperform ReAct and DICE in Texture dataset, which can be compensated by combining ReAct.

In Table 2, we compare our proposal with competitive post-hoc OOD detection methods based on ViT-B/16 model. We note that the performance of MSP [21] and Energy Score [31] in previous work [9] is worse than our implementation based on the same model, therefore, we reported the performance reproduced by ourselves. The results show that: (1) Both OPP and ONP outperforms Energy baseline [31] by a large margin, which demonstrates the effectiveness of our proposal in ViT model. (2) OPP outperforms ONP and combining parameter and neuron pruning (OPNP) does not further improve the OOD performance, which is different from the results in ResNet50. We think this is because the number of neurons in ViT-B/16 (768) is much less than in ResNet50 (2048), besides, there is a relu layer before pre-logit layer in ResNet, which results in more risky parameters and neurons in ResNet50 model. (3) OPP outperforms ReAct by 1.85% and outperforms DICE by 3.91%in FPR95, combining OPP and ReAct brings additional improvement.

Evaluation on CIFAR benchmark. The main results on CIFAR10 and CIFAR100 benchmarks are show in Table 5 and Table 6. As can be seen, we consider the three most commonly used post-hoc methods and compare the OOD detection performance with and without applying the OPNP. The results show that: (1) On both CIFAR10 and CIFAR100, using OPNP consistently outperforms the counterpart without OPNP, which indicates that our proposal is compatible with other post-hoc methods. (2) The performance improvement brought by OPNP on CIFAR100 is more significant than on CIFAR10 and less significant than on ImageNet benchmark. We believe this is because the FC layer on CIFAR10 classification model is much less overparameterized than CIFAR100 and ImageNet classification models. (3) The OPNP achieves similar performance as ReAct On CIFAR10 benchmark, and outperforms ReAct on CIFAR100 benchmark. Besides, utilizing OPNP and ReAct jointly reduces FPR95 by 1.55% and 2.49% in CIFAR10 and CIFAR100 benchmark, respectively.

0.1

0.3

0.5

1.0

3.0

5.0

ρ w

35.0

37.5

40.0

42.5

45.0

47.5

50.0

52.5

55.0

FPR95

SUN

Places

(a) Sensitivity of

ρ

w

10

20

30

40

50

60

ρ w

min

25

30

35

40

45

50

FPR95

SUN

Places

(b) Sensitivity of

ρ

w

min

1

5

10

20

30

50

ρ o

25

30

35

40

45

50

55

FPR95

SUN

Places

(c) Sensitivity of

ρ

o

1

5

10

20

30

50

ρ o

min

25.0

27.5

30.0

32.5

35.0

37.5

40.0

42.5

45.0

FPR95

SUN

Places

(d) Sensitivity of

ρ

o

min

(a) Distribution

(b) Uncalibrated

(c) After OPNP

ConfidenceHistogram

ConfidenceReliabilityDiagram

ConfidenceReliabilityDiagram

1.0

1.0

0.5

0.8

Confidence

0.8-

Confidence

0.4

ECE=3.647%

ECE=2.146%

0.6

0.6

0.3

0.2

0.4

0.4

0.1

0.2

0.2

0.0+

0.0+

0.0+

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

0.6

0.8

1.0

0.0

0.2

0.4

0.6

0.8

1.0

4.3 Ablation Studies.

Effect of pruning percentage. In Fig. 3, we demonstrate the impact on OOD detection performance by varying pruning percentages in two different tasks. Fig. 3(a) shows that pruning only 0.5% high sensitivity parameters brings significant improvement. In Fig. 3(b), we observe considerable performance improvement with a large pruning percentage for low sensitive parameters. Fig. 3(c) and Fig. 3(d) suggest that pruning high sensitive neurons is more effective than pruning low sensitive neurons, which brings marginal improvement. While OPNP achieves the SOTA performance, the performance could be significantly improved by pruning only the weights or neurons, which is much simple to determine the thresholds. Besides, the performance is improved and insensitive in a wide range of pruning ratio. For example, the optimal pruning ratio can be set to ρ w min ∈ [10 , 30] and ρ w max ∈ [0 . 5 , 3] across different OOD sets. In Tabel 3, we demonstrate the impact of different pruning percentages on ID classification accuracy. As observed, pruning only 1.0% high sensitive parameters decreases the ID accuracy by 4.53%. In contrast, pruning 40% low sensitive parameters only reduces ID accuracy by 1.07%. This highlights the effectiveness of our sensitivity estimation method, and also demonstrates the significant parameter redundancy in deep networks.

Ablation on pruning methods. In this ablation, we compare the proposed sensitivity guided parameter and neuron pruning method with other pruning method, including: (1) Random parameter pruning (RPP) [48]; (2) Target parameter pruning (TPP) [15], which prunes weights with low magnitude; (3) Random neuron pruning (RNP) [42]; and (4) Target neuron pruning (TNP) [15], which prunes neurons with low feature norm. For the comparison methods, we try different pruning percentages and report the best results. The ablation results in Table. 4 reveal that: (1) pruning

(a) Energy-SUN

(b) OPNP-SUN

(c) Energy-Places

(d) OPNP-Places

Energy score distribution

Energyscore distribution

Energy score distribution

Energyscore distribution

1750

OOD (SUN)

OOD (SUN)

1750

OOD (Places)

OOD (Places)

1500

ID (lmageNet-1K)

2500

ID (lmageNet-1K)

1500

ID (ImageNet-1K)

2500

ID (lmageNet-1K)

Frequency

1250

Frequency

2000

Frequency

1250

Frequency

2000

1000

1500

1000

1500

750

750

1000

1000

500

500

250

500

250

500

0

=45

=40

35

Energy Scores

=30

15

-10

Energy Scores

0

45

40

=35

Energy Scores

30

25

20

15

-10

0-

Energy Scores

parameters and neurons with low magnitude outperforms random parameter and neuron pruning. (2) The introduced optimal parameter and neuron pruning outperforms other pruning methods by a margin margin, with 16.68% improvement in SUN dataset and 18.95% in Places dataset.

OPNP benefits model calibration. A well calibrated model should have better OOD detection performance [16]. In this ablation, we explore how OPNP influences model calibration. In Fig. 4, we evaluate model calibration performance with Confidence Reliability Diagrams (CRD) and Expected Calibration Error (ECE), which was introduced in [16]. As observed in Fig. 4(b), for an uncalibrated model, the confidence obviously exceeds accuracy, which indicates overconfident confidence. Fig. 4(c) illustrates the effect of utilizing OPNP, which shows that the consistency between confidence and accuracy is improved, and the ECE is reduced by 1.5%. It demonstrates that OPNP is beneficial to model calibration, which also explains why OPNP improves OOD detection performance.

How OPNP changes the score distribution In Fig. 5, we illustrate the OOD score distribution with the Energy baseline [31] and our proposed OPNP. We utilize SUN and Places benchmarks with ResNet50 model to exhibit how the OPNP changes the OOD score distributions. From the illustration, several interesting observations are: (1) Utilizing OPNP increases OOD scores for both ID and OOD samples. (2) The utilization of OPNP has a significant impact on the score distribution of OOD samples, resulting in a more condensed distribution. (3) The OOD score distributions of ID and OOD samples become more separable after applying OPNP, which validates the effectiveness of optimal parameter and neuron pruning.

5 Conclusion

Conclusion and future work. In this paper, we propose a simple yet effective post-hoc OOD detection method. In particular, a gradient-based method is proposed to estimate the sensitivity of model parameters and neurons. We show that the OOD detection performance could be significantly improved by simply removing the connection weights and neurons with exceptionally large or close to zero sensitivities. Extensive experiments and ablations are performed to demonstrate the effectiveness of our proposal. Compared to energy score baseline, our OPNP reduces FPR95 by 32.5% in ImageNet-1K benchmark. Besides, the OPNP outperforms the SOTA feature rectification method by 5.5% in FPR95 and outperforms the SOTA weight pruning method by 8.8% in FPR95. We believe the optimal parameter and neuron pruning is a promising direction for OOD detection tasks, and hope our findings can bring new ideas and breakthroughs to other researchers. In our future work, we will explore other post-hoc model pruning and quantization method, as well as low rank decomposition of model parameters for OOD detection.

Limitation and societal impact. The main limitation of this work is lack of theoretical guarantee. Therefore, we call for further application and explanation of the sensitivity guided parameter and neuron pruning method for OOD detection. This work aims to improve the safety of modern deep learning models, which tends to benefit a wide range of applications in social life, such as AI for medical, smart city and driverless system. We hope to provide a plug-and-play tool for AI model users to reduce the false recognition caused by OOD samples in the real world.

Acknowledgments and Disclosure of Funding

This work was supported by the National Key R&D Program of China under Grant 2020AAA0103902.

References

Rahaf Aljundi, Francesca Babiloni, Mohamed Elhoseiny, Marcus Rohrbach, and Tinne Tuytelaars. Memory aware synapses: Learning what (not) to forget. In Proceedings of the European conference on computer vision (ECCV) , pages 139-154, 2018.

Jiefeng Chen, Yixuan Li, Xi Wu, Yingyu Liang, and Somesh Jha. Atom: Robustifying out-ofdistribution detection using outlier mining. In Machine Learning and Knowledge Discovery in Databases. Research Track: European Conference, ECML PKDD 2021, Bilbao, Spain, September 13-17, 2021, Proceedings, Part III 21 , pages 430-445. Springer, 2021.

Zhen Cheng, Fei Zhu, Xu-Yao Zhang, and Cheng-Lin Liu. Average of pruning: Improving performance and stability of out-of-distribution detection. arXiv preprint arXiv:2303.01201 , 2023.

Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In Proceedings of the IEEE conference on computer vision and pattern recognition , pages 3606-3613, 2014.

Guneet S Dhillon, Kamyar Azizzadenesheli, Zachary C Lipton, Jeremy D Bernstein, Jean Kossaifi, Aran Khanna, and Animashree Anandkumar. Stochastic activation pruning for robust adversarial defense. In International Conference on Learning Representations .

Andrija Djurisic, Nebojsa Bozanic, Arjun Ashok, and Rosanne Liu. Extremely simple activation shaping for out-of-distribution detection. arXiv preprint arXiv:2209.09858 , 2022.

Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations .

Xuefeng Du, Xin Wang, Gabriel Gozum, and Yixuan Li. Unknown-aware object detection: Learning what you don't know from videos in the wild. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 13678-13688, 2022.

Xuefeng Du, Zhaoning Wang, Mu Cai, and Yixuan Li. Vos: Learning what you don't know by virtual outlier synthesis. arXiv preprint arXiv:2202.01197 , 2022.

Sepideh Esmaeilpour, Bing Liu, Eric Robertson, and Lei Shu. Zero-shot out-of-distribution detection based on the pre-trained model clip. In Proceedings of the AAAI conference on artificial intelligence , volume 36, pages 6568-6576, 2022.

Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur. Sharpness-aware minimization for efficiently improving generalization. In International Conference on Learning Representations , 2020.

Stanislav Fort, Jie Ren, and Balaji Lakshminarayanan. Exploring the limits of out-of-distribution detection. Advances in Neural Information Processing Systems , 34:7068-7081, 2021.

Jonathan Frankle and Michael Carbin. The lottery ticket hypothesis: Finding sparse, trainable neural networks. arXiv preprint arXiv:1803.03635 , 2018.

Chuanxing Geng, Sheng-jun Huang, and Songcan Chen. Recent advances in open set recognition: A survey. IEEE transactions on pattern analysis and machine intelligence , 43(10):36143631, 2020.

Aidan N Gomez, Ivan Zhang, Siddhartha Rao Kamalakara, Divyam Madaan, Kevin Swersky, Yarin Gal, and Geoffrey E Hinton. Learning sparse networks using targeted dropout. arXiv preprint arXiv:1905.13678 , 2019.

Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q Weinberger. On calibration of modern neural networks. In International conference on machine learning , pages 1321-1330. PMLR, 2017.

Song Han, Jeff Pool, John Tran, and William Dally. Learning both weights and connections for efficient neural network. Advances in neural information processing systems , 28, 2015.

Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition , pages 770-778, 2016.

Matthias Hein, Maksym Andriushchenko, and Julian Bitterwolf. Why relu networks yield high-confidence predictions far away from the training data and how to mitigate the problem. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 41-50, 2019.

Dan Hendrycks, Steven Basart, Mantas Mazeika, Andy Zou, Joseph Kwon, Mohammadreza Mostajabi, Jacob Steinhardt, and Dawn Song. Scaling out-of-distribution detection for realworld settings. In International Conference on Machine Learning , pages 8759-8773. PMLR, 2022.

Dan Hendrycks and Kevin Gimpel. A baseline for detecting misclassified and out-of-distribution examples in neural networks. In International Conference on Learning Representations .

Dan Hendrycks, Mantas Mazeika, and Thomas Dietterich. Deep anomaly detection with outlier exposure. In International Conference on Learning Representations .

Torsten Hoefler, Dan Alistarh, Tal Ben-Nun, Nikoli Dryden, and Alexandra Peste. Sparsity in deep learning: Pruning and growth for efficient inference and training in neural networks. The Journal of Machine Learning Research , 22(1):10882-11005, 2021.

Rui Huang, Andrew Geng, and Yixuan Li. On the importance of gradients for detecting distributional shifts in the wild. Advances in Neural Information Processing Systems , 34:677689, 2021.

John Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Žídek, Anna Potapenko, et al. Highly accurate protein structure prediction with alphafold. Nature , 596(7873):583-589, 2021.

Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. Advances in neural information processing systems , 31, 2018.

Hao Li, Asim Kadav, Igor Durdanovic, Hanan Samet, and Hans Peter Graf. Pruning filters for efficient convnets. In International Conference on Learning Representations .

Yi Li and Nuno Vasconcelos. Background data resampling for outlier-aware classification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 13218-13227, 2020.

Shiyu Liang, Yixuan Li, and R Srikant. Enhancing the reliability of out-of-distribution image detection in neural networks. In 6th International Conference on Learning Representations, ICLR 2018 , 2018.

Shiwei Liu, Tianlong Chen, Zahra Atashgahi, Xiaohan Chen, Ghada Sokar, Elena Mocanu, Mykola Pechenizkiy, Zhangyang Wang, and Decebal Constantin Mocanu. Deep ensembling with no overhead for either training or testing: The all-round blessings of dynamic sparsity. In International Conference on Learning Representations , 2021.

Weitang Liu, Xiaoyun Wang, John Owens, and Yixuan Li. Energy-based out-of-distribution detection. Advances in neural information processing systems , 33:21464-21475, 2020.

Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. In International Conference on Learning Representations .

Christos Louizos, Max Welling, and Diederik P Kingma. Learning sparse neural networks through l_0 regularization. In International Conference on Learning Representations .

TorchVision maintainers and contributors. Torchvision: Pytorch's computer vision library. https://github.com/pytorch/vision , 2016.

Yifei Ming, Ziyang Cai, Jiuxiang Gu, Yiyou Sun, Wei Li, and Yixuan Li. Delving into out-ofdistribution detection with vision-language representations. In Advances in Neural Information Processing Systems .

Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. 2011.

Anh Nguyen, Jason Yosinski, and Jeff Clune. Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. In Proceedings of the IEEE conference on computer vision and pattern recognition , pages 427-436, 2015.

Alec Radford, Karthik Narasimhan, Tim Salimans, Ilya Sutskever, et al. Improving language understanding by generative pre-training. 2018.

Jie Ren, Peter J Liu, Emily Fertig, Jasper Snoek, Ryan Poplin, Mark Depristo, Joshua Dillon, and Balaji Lakshminarayanan. Likelihood ratios for out-of-distribution detection. Advances in neural information processing systems , 32, 2019.

Lukas Ruff, Jacob R Kauffmann, Robert A Vandermeulen, Grégoire Montavon, Wojciech Samek, Marius Kloft, Thomas G Dietterich, and Klaus-Robert Müller. A unifying review of deep and shallow anomaly detection. Proceedings of the IEEE , 109(5):756-795, 2021.

Simone Scardapane, Danilo Comminiello, Amir Hussain, and Aurelio Uncini. Group sparse regularization for deep neural networks. Neurocomputing , 241:81-89, 2017.

Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research , 15(1):1929-1958, 2014.

Yiyou Sun, Chuan Guo, and Yixuan Li. React: Out-of-distribution detection with rectified activations. Advances in Neural Information Processing Systems , 34:144-157, 2021.

Yiyou Sun and Yixuan Li. Dice: Leveraging sparsification for out-of-distribution detection. In European Conference on Computer Vision , 2022.

Yiyou Sun, Yifei Ming, Xiaojin Zhu, and Yixuan Li. Out-of-distribution detection with deep nearest neighbors. In International Conference on Machine Learning , pages 20827-20840. PMLR, 2022.

Hidenori Tanaka, Daniel Kunin, Daniel L Yamins, and Surya Ganguli. Pruning neural networks without any data by iteratively conserving synaptic flow. Advances in neural information processing systems , 33:6377-6389, 2020.

Leitian Tao, Xuefeng Du, Jerry Zhu, and Yixuan Li. Non-parametric outlier synthesis. In The Eleventh International Conference on Learning Representations .

Li Wan, Matthew Zeiler, Sixin Zhang, Yann Le Cun, and Rob Fergus. Regularization of neural networks using dropconnect. In International conference on machine learning , pages 1058-1066. PMLR, 2013.

Ross Wightman. Pytorch image models. https://github.com/rwightman/ pytorch-image-models , 2019.

Pingmei Xu, Krista A Ehinger, Yinda Zhang, Adam Finkelstein, Sanjeev R Kulkarni, and Jianxiong Xiao. Turkergaze: Crowdsourcing saliency with webcam based eye tracking. arXiv preprint arXiv:1504.06755 , 2015.

Jingkang Yang, Kaiyang Zhou, Yixuan Li, and Ziwei Liu. Generalized out-of-distribution detection: A survey. arXiv preprint arXiv:2110.11334 , 2021.

Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser, and Jianxiong Xiao. Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop. arXiv preprint arXiv:1506.03365 , 2015.

Jingzhao Zhang, Tianxing He, Suvrit Sra, and Ali Jadbabaie. Why gradient clipping accelerates training: A theoretical justification for adaptivity. In International Conference on Learning Representations , 2019.

Xingxuan Zhang, Renzhe Xu, Han Yu, Hao Zou, and Peng Cui. Gradient norm aware minimization seeks first-order flatness and improves generalization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 20247-20257, 2023.

Yang Zhao, Hao Zhang, and Xiuyuan Hu. Penalizing gradient norm for efficiently improving generalization in deep learning. In International Conference on Machine Learning , pages 26982-26992. PMLR, 2022.

Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 million image database for scene recognition. IEEE transactions on pattern analysis and machine intelligence , 40(6):1452-1464, 2017.

Yao Zhu, YueFeng Chen, Chuanlong Xie, Xiaodan Li, Rong Zhang, Hui Xue, Xiang Tian, Yaowu Chen, et al. Boosting out-of-distribution detection with typical features. arXiv preprint arXiv:2210.04200 , 2022.

A Evaluation on CIFAR Benchmarks

A.1 Experimental setup

We additionally evaluate our proposal on the widely used CIFAR benchmarks with CIFAR10 and CIFAR100 as ID datasets. The standard split with 50,000 training ID images and 10,000 test ID images are utilized for training and evaluation. We following [43, 44] to evaluate on six common OOD datasets 4 , including iSUN [50], LSUN-Resize [52], LSUN-Crop [52], SVHN [36], Places365 [56], and Textures [4]. Please refer to [44] for the details of the datasets. For both CIFAR10 and CIFAR100 datasets, we train a standard ResNet50 [18] model for 100 epochs. The learning rate is set to 0.01 and cosine annealing [32] is utilized for learning rate decay. The final accuracy of CIFAR10 and CIFAR100 classification model is 96.44% and 85.27% respectively.

A.2 Main results

The main results on CIFAR10 and CIFAR100 benchmarks are show in Table 5 and Table 6. As can be seen, we consider the three most commonly used post-hoc methods and compare the OOD detection performance with and without the applying OPNP. The results show that: (1) On both CIFAR10 and CIFAR100, using OPNP consistently outperforms the counterpart without OPNP, which indicates that our proposal is compatible with other post-hoc methods. (2) The performance improvement brought by OPNP on CIFAR100 is more significant than on CIFAR10 and less significant than on ImageNet benchmark. We believe this is because the output layer on CIFAR10 classification model, which has fewer connection weights, is much less overparameterized than CIFAR100 and ImageNet classification models. (3) The OPNP achieves similar performance as ReAct On CIFAR10 benchmark, and outperforms ReAct on CIFAR100 benchmark. Besides, utilizing OPNP and ReAct jointly reduces FPR95 by 1.55% and 2.49% in CIFAR10 and CIFAR100 benchmark, respectively.

B More Ablation Studies

B.1 Perform OPNP on different layers

In our main experiments, we apply the OPNP in the last FC layer in both ResNet50 and ViT-B/16. In this ablation, we also utilize the proposed OPNP in different intermediate layers of ResNet50.

As illustrated in Table. 7, we utilize the OPNP in four different convolutional layers, Layer1Layer4, which represent the kernel weights of the last 1 × 1 convolutional layer in four ResBlocks of ResNet50. The results show that utilizing the OPNP in the last FC layer significantly outperforms the performance by using OPNP in the intermediate convolutional layers, which indicates that the overconfident predictions mainly comes from the last fully connected layer. Besides, we also estimate the parameter sensitivity of the whole model and pruning the weights with two globally pruning strategies, including (1) Global Threshold Pruning: pruning all the weights in Convolution layer and FC layer in a global threshold. (2) Layer-wise Pruning: pruning the weights in different layer individually with the same pruning ratio. We find that both global pruning methods perform worse than only pruning the FC layer. To help understand what happens when weights are pruned globally, we illustrate the average parameter sensitivity of different layers in Fig. 6. It shows that the sensitivity magnitude across different layers differs greatly, the sensitivity of the FC layer is less than 1 10 of the shallow Convolution layer. Therefore, it is unreasonable to utilize a global threshold for all layers. It might be work if we use different thresholds for different layers, but it is too tricky to determine the optimal thresholds.

AveragesensitivityfordifferentlayersinResNet50

F00000L

Ssensitivity

600000

500000

layer:

400000

300000

Average

200000

100000

0

0

20

40

60

80

100

120

140

160

Layerindex

B.2 Parameter sensitivity estimation with different number of training samples.

To reduce the cost for parameter sensitivity estimation, it is advisable to compute the parameter sensitivity based on a subset of the training set rather than the entire set. To demonstrate the effectiveness of using a subset for sensitivity estimation. We randomly select 1%, 5%, 20% and 100% training samples for sensitivity estimation, and perform parameter pruning based on the sensitivities. The experimental results are shown in Table 8, which demonstrate that using only 1% of the training set (ImageNet-1K) also achieves promising performance.

B.3 Neuron sensitivity estimation with different statistics

In the main experiments, we utilize the average sensitivity (equivalent to ℓ 1 norm ) as the neuron sensitivity. It is worth noting that other statistics, such as ℓ 2 norm, Variance, Maximum (Max),

Minimum (Min) and Median may also feasible statistics to measure the neuron sensitivity. Therefore, we compare the performance of using different statistics as the neuron sensitivity. The results are presented in Figure 9, which show that using the Mean, Min and Median of the weights sensitivity as neuron sensitivity achieve similar performance, and using the Variance statistic performs worst. As the Mean value is more robust and less likely to be susceptible by noisy connections, we suggest the users utilize the Mean statistic of parameter sensitivity for neuron pruning.

C Sensitivity Distribution Visualization

C.1 Parameter and neuron sensitivity distribution on CIFAR benchmarks.

In Fig. 7 and Fig. 8, we illustrate the parameter and neuron sensitivity distribution for CIFAR10 and CIFAR100 classification models, which reveal several interesting insights. First, on both CIFAR10 and CIFAR100 classification models, there are a few parameters that exhibit exceptionally high sensitivities and close to zero sensitivities, which is consistent with the sensitivity distribution on the ImageNet benchmark. Second, there are more parameters with close to zero sensitivities and more neurons with abnormal sensitivities on CIFAR100 classification model, which explains why OPNP brings more performance gains on CIFAR100 benchmark.

0.0

0.2

0.4

0.6

0.8

1.0

Normalized parameter sensitivity

0

1

2

3

4

5

6

7

8

Density

Parameter sensitivity distribution in CIFAR10

(a) CIFAR10

0.0

0.2

0.4

0.6

0.8

1.0

Normalized parameter sensitivity

0

2

4

6

8

10

12

Density

Parameter sensitivity distribution in CIFAR100

(b) CIFAR100

C.2 Parameter Sensitivity Distribution of the Pruned Weights

The parameter sensitivity distribution (on ID and OOD set) of the pruned weights is illustrated in Fig. 9. The results show that the pruned weights contain many high sensitive connections for OOD set.

0.2

0.4

0.6

0.8

1.0

Normalized neuron sensitivity

0

1

2

3

4

5

Density

Neuron sensitivity distribution in CIFAR10

(a) CIFAR10

0.2

0.4

0.6

0.8

1.0

Normalized neuron sensitivity

0

1

2

3

4

5

6

7

Density

Neuron sensitivity distribution in CIFAR100

(b) CIFAR100

Besides, the average sensitivity on OOD set (0.00024) is larger than the average sensitivity on ID set (0.00018), which experimentally verifies Eq. 11.

SensitivitydistributiononIDand OoDsamples

105

OOD

ID

104

Frequency

103

102

101

100

Parametersensitivity

D Discussion

The whole OOD detection pipeline is presented in Algorithm 1. In the main experiments, we integrate parameter pruning and neuron pruning in a unified framework, which actually can be used individually. The effectiveness of parameter and neuron pruning may vary for different model architectures and ID tasks. Therefore, we recommend readers to attempt different pruning percentage combinations for different tasks. Energy score [31], ReAct [43], DICE [44] ans ASH [6] are the most relevant researches to our work. The difference between our OPNP and the baseline method - Energy Score [31] is that we remove some output connections and hidden neurons according to pre-computed parameter and neuron sensitivities. Different from ReAct [43], which clips features with abnormal magnitude, our OPNP removes the parameters and neurons with abnormal sensitivity. The differences between our method and DICE [44] are: (1) DICE obtains the weight importance by averaging the contribution of weights to logit output, while our method measures the parameter and neuron sensitivity to energy score by averaging gradient; (2) DICE only removes the weights with low importance, while our OPNP not only removes the non-sensitive connections and neurons but also remove the most sensitive ones. Besides, ASH clips or binarizes the features based on the magnitude to improve OOD performance, whereas our OPNP prunes both weights and neurons based on sensitivity. Compared to those methods that also explore sparsity to improve OOD detection performance, the

introduced sensitivity metric measured by output energy is directly coupled with OOD detection tasks, and the sensitivity guided pruning is more intuitive, comprehensive and user-friendly.

Algorithm 1 OPNP - Optimal Parameter and Neuron Pruning Input: A trained model f ( x ; θ ) , training samples { x i } i m =1 , pruning percentage ρ w max , ρ w min , ρ o min , ρ o max , test sample { x k } n k =1 ; Output: Energy score of test sample { E ( x k ) } n k =1 1: for i = 1 to m do 2: compute gradient g ( x i ) ; 3: end for 4: M = 1 m ∑ m k =1 | g ( x k ) | ; 5: O i = 1 K ∑ K p =1 M ip , i = 1 , · · · , L ; 6: Get threshold Ω w min , Ω w max by ranking M ; 7: Get threshold Ω o min , Ω o max by ranking O ; 8: W [ M > Ω w max ] = 0 and W [ M < Ω w min ] = 0 ; 9: for k = 1 to n do 10: Compute the pre-logit embedding h ( x k ) ; 11: h ( x k )[ O > Ω o max ] = 0 and h ( x k )[ O < Ω o min ] = 0 ; 12: f ( x k ) = W · h ( x k ) + b ; 13: E ( x k ) = -log ∑ K i =1 exp( f i ( x k )) ; 14: end for 15: Return { E ( x k ) } n k =1

Peer reviews:
comments: SUMMARY:
This paper contributes a new parameter and neuron pruning methods for OOD detection. Built upon the energy-based score, this paper defines the sensitivity of a parameter (neuron) wrt the energy-score by using gradient.

STRENGTHS:
The arguments are clear and easily understood. The method is well motivated by removing the weights and neurons. The experiments are comprehensive and clear, and the results are promising.

WEAKNESSES:
$\bullet$ The major weakness is the theoretical explanation between the sensitivity and OOD performance, but this is clearly pointed out in the paper.

$\bullet$ The usage of the sensitivity is based on intuition, while this is a good technique for solving OOD problems.

QUESTIONS:
$\bullet$ What are the techniques (feature ensemble or/and input preprocessing) used in Mahalanbis score in comparison?

$\bullet$ This pruning method seems to be very promising. I understand this was discussed as limitation and future work, but is it possible to share the insights why the sensitivity term(s) will work?

LIMITATIONS:
The limitations are fully discussed with explanations.
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2023-06-25

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper proposes a parameter and neuron pruning strategy to enhance out-of-distribution detection. The approach involves removing near-zero- and high-sensitivity parameters, which are measured by the average gradient corresponding to all training in-distribution samples. Empirical results demonstrate the superior performance of the proposed algorithm.\n\nSTRENGTHS:\nThe proposed algorithm is characterized by its simplicity and remarkable effectiveness in out-of-distribution detection tasks, exhibiting consistently high performance.\n\nWEAKNESSES:\nWhile the proposed principle shows promising results, providing theoretical explanations for its success would be valuable. Additionally, selecting the appropriate hyper-parameters beforehand presents challenges.\n\nQUESTIONS:\nAlthough empirical evidence indicates performance gains when pruning the largest sensitivity value (as seen in Figure 3), understanding its behavior and identifying optimal values require further investigation. Users would benefit from discussions clarifying such cases and receiving intuitive suggestions to aid in parameter selection. Additionally, exploring the impact of using a fixed threshold instead of a percentile for pruning sensitivity values may lead to improved performance.\n\nThe reliance on the average sensitivity of connection weights for neuron pruning lacks an intuitive explanation. Other statistics, such as min, max, or median, could also be considered as potential alternatives.\n\nAn explicit explanation of how to combine OPNP with ReAct should be provided.\n\nTo enhance efficiency, it is advisable to consider pruning based on a subset of the training set rather than the entire set.\n\nLIMITATIONS:\nThe authors have addressed some limitations of their work, and there are additional suggestions for improvement in the 'Paper Weakness'' part and \"Questions\" part.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-03"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis submission proposes a post-hoc method for detecting out-of-distribution samples, by pruning the final classification layer, using a sensitivity metric based on the gradients of the energy scores. The proposed method is mainly validated on residual networks and visual transformers based on the ImageNet dataset.\n\nSTRENGTHS:\n- The submission proposes an interesting application using pruning to out-of-distribution detection, the latter being an important research problem\n- The proposed method is simple, and can be applied with a fairly small computational overhead\n- The results suggest that the proposed method, also when used in conjunction with other methods, can achieve state-of-the-art results on several tasks.\n\nWEAKNESSES:\n- The submission is not very well written, particularly the introduction, with quite a few typos and grammar issues (e.g. using “post-hot” instead of “post-hoc” in quite a few places). This makes reading a bit difficult. \n- The proposed method is not very novel, as other OOD detection methods have used pruning (e.g. references 20, 35 seem quite similar)\n- The performance of the method depends quite heavily on the pruning thresholds (see Figure 3) and can substantially decrease the accuracy on the original ID classification task (see Table 3). This makes the method less likely to be used “out of the box”.\n- While the authors introduce their method as \"post-hoc\", in fact it has a similar cost to training the model for one epoch, since the gradients for all the samples have to be computed.\n\nQUESTIONS:\n- Suggestion: I would advise the authors to go through the submission and correct the typos and grammar issues, for the next revision\n- I believe Equation (4) is an approximation, rather than an identity. Have the authors considered what would be a theoretical explanation that would connect the approximation in Equation (4) and the removal of least and most sensitive weights?\n- What is the norm in Equation (6)? Should it be an absolute value instead?\n- Can the authors provide more explanations on the intuition that “parameters and neurons with exceptionally large sensitivity can easily lead to overconfidence” (51-52)?\n- Lines 145-147: it is hard to see these differences from Figure 1, I would suggest adding numbers\n- Lines 181-182: this is not really a Gaussian (e.g it is not symmetric)\n- Can you provide more details on how OPNP is combined with ReAct?\n- In Table 2, can you provide results for DICE + ReAct?\n- Some of the plots and tables do not include information about the model and dataset used. For example, what is the model used in Table 3 or Table 4? What is the model and dataset from Figure 4?\n- The authors show results when (independently) pruning other layers in a ResNet50 model (Appendix Table 3). What happens if the weights are pruned globally, instead of each layer at a time?\n- Have the authors considered second order information for computing the sensitivity metric? For example, a second order Taylor approximation could be used instead of Equation (4), and since pruning is only done for the final layer, the Hessian could be more easily calculated. This is a similar approach to Optimal Brain Surgeon (Hassibi et al.)\n- Can you clarify what is meant by \"(subset of) iNaturalist, SUN, Place and Texture\" (line 211)? Are the same corresponding datasets used for evaluation when comparing with the other methods from Tables 1 and 2?\n- Can you please confirm that the ID test set used for validation (and determining the pruning hyperparameters and OOD threshold) was different than the one used for the final testing?\n- Can you please clarify the differences between Algorithm 1 and the text which specifies that the parameter and neuron sensitivities are computed based on the entire training set? In line 5 from Algorithm 1, it sounds like neuron pruning is done individually for each sample, but from the text the neuron sensitivities are computed on the entire training set. In my understanding, the model is pruned only once, and the same sparse model is used for evaluation on different OOD tasks. Can you please confirm whether my understanding is correct?\n\nLIMITATIONS:\nWhile the authors have addressed some of the limitations of their work in Section 5, I believe the proposed method, in its current form, has some technical limitations that would make it more difficult to use “plug-and-play” as the authors hope. For example, the method relies quite heavily on the optimal hyperparameters (thresholds) for pruning and it can have a substantial negative impact on the ID classification accuracy for the original task. I would advise the authors to consider how the search of the pruning hyperparameters could be automatized, or at least made more efficient. \n\n--------------------------------\n**Edited after rebuttals**\n\nAfter reading the authors' answer, I have raised my score from 4 to 5.", "TITLE": "Official Review", "RECOMMENDATION": 5, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 2, "DATE": "2023-07-06"}

comments: SUMMARY:
This paper proposes to adopt weight and neuron pruning for OOD detection. The proposed method is able to be combined with training-based approaches, demonstrating SOTA performance.

STRENGTHS:
1. The motivation of the method is reasonable and sound. 

2. The results of OPNP+ReAct is strong.

WEAKNESSES:
1. It is not new for the ML community that sparsity can help improve OOD detection. Numerous related works have been proposed to adopt sparsity/pruning to improve OOD detection. While might having different pruning approaches, it is necessary to discuss and compare them in the submission.  

[1] Cheng, Zhen, et al. "Average of pruning: Improving performance and stability of out-of-distribution detection." arXiv preprint arXiv:2303.01201 (2023). 

[2] Djurisic, Andrija, et al. "Extremely simple activation shaping for out-of-distribution detection." arXiv preprint arXiv:2209.09858 (2022).

[3] Sun, Yiyou, and Yixuan Li. "Dice: Leveraging sparsification for out-of-distribution detection." European Conference on Computer Vision. Cham: Springer Nature Switzerland, 2022.

[4] Liu, Shiwei, et al. "Deep ensembling with no overhead for either training or testing: The all-round blessings of dynamic sparsity." arXiv preprint arXiv:2106.14568 (2021).

2. The pseudocode of Algorithm 1 looks very trivial, and can be significantly improved.

QUESTIONS:
See the above limitation.

LIMITATIONS:
n/a
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2023-07-07