Next Article in Journal
UVCS: Unit Virtual Coordinate System for UAV Intra-Swarm Routing in GPS-Denied Environment
Next Article in Special Issue
Retrieval-Augmented Knowledge Graph Reasoning for Commonsense Question Answering
Previous Article in Journal
Analysis of Error and Stability of Nanofluid over Horizontal Channel with Heat/Mass Transfer and Nonlinear Thermal Conductivity
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

AdvSCOD: Bayesian-Based Out-Of-Distribution Detection via Curvature Sketching and Adversarial Sample Enrichment

1
Cyberspace Institute of Advanced Technology, Guangzhou University, Guangzhou 510006, China
2
School of Artificial Intelligence, Optics, and Electronics (iOPEN), Northwestern Polytechnical University, Xi’an 710072, China
3
Department of New Networks, Peng Cheng Laboratory, Shenzhen 518066, China
*
Author to whom correspondence should be addressed.
Mathematics 2023, 11(3), 692; https://doi.org/10.3390/math11030692
Submission received: 15 December 2022 / Revised: 20 January 2023 / Accepted: 27 January 2023 / Published: 29 January 2023
(This article belongs to the Special Issue Applications of Big Data Analysis and Modeling)

Abstract

:
Detecting out-of-distribution (OOD) samples is critical for the deployment of deep neural networks (DNN) in real-world scenarios. An appealing direction in which to conduct OOD detection is to measure the epistemic uncertainty in DNNs using the Bayesian model, since it is much more explainable. SCOD sketches the curvature of DNN classifiers based on Bayesian posterior estimation and decomposes the OOD measurement into the uncertainty of the model parameters and the influence of input samples on the DNN models. However, since lots of approximation is applied, and the influence of the input samples on DNN models can be hardly measured stably, as demonstrated in adversarial attacks, the detection is not robust. In this paper, we propose a novel AdvSCOD framework that enriches the input sample with a small set of its neighborhoods generated by applying adversarial perturbation, which we believe can better reflect the influence on model predictions, and then we average their uncertainties, measured by SCOD. Extensive experiments with different settings of in-distribution and OOD datasets validate the effectiveness of AdvSCOD in OOD detection and its superiority to state-of-the-art Bayesian-based methods. We also evaluate the influence of different types of perturbation.

1. Introduction

Deep neural networks (DNNs) [1,2,3,4] have revolutionized the solution of a variety of computer vision tasks, e.g., image classification and semantic segmentation, and they have refreshed the state-of-the-art records. However, since these DNN models are designed under the closed-world assumption [5], they can be hardly deployed in real-world scenarios directly. One of the major obstacles is the out-of-distribution (OOD) samples that inevitably exist. Indeed, many recent studies have reported that DNN models make overconfident predictions on OOD samples [6] and thus have hidden risks in terms of safety issues.
Current solutions to deal with OOD overconfidence issues can be broadly divided into two categories. One branch of research focuses on alleviating the issue by suppressing the prediction confidences on a small set of typical OOD samples [7,8]. However, since the suppression on this typical set can hardly generalize to all OOD samples, the OOD overconfidence issue still exists. The other branch of research instead conducts pre-step OOD detection, and thus can reject OOD samples before feeding them to the DNN models.
To conduct OOD detection, many OOD scores that show how likely a sample is to be OOD have been recently devised. Hendrycks et al. [9] proposed utilizing probabilities from softmax distributions of DNN classifiers. Though simple, this solution is validated as often being sufficient for OOD detection. Later, researchers have investigated the improvement of OOD detection by utilizing temperature scaling and adding small perturbations [10], Mahalanobis distance [11], energy-based models [12], logit normalization [13], etc. Although good detection performance has been shown, it is hardly explainable how this is attributable to these OOD scores.
An orthogonal yet more appealing direction is to employ Bayesian models to reformulate the problem [14], since it is much more explainable to some extent. The rationale behind this direction is that the uncertainty of input samples, i.e., the likelihood of being OOD, is usually highly related to the uncertainty of DNN parameters, which can be measured by Bayesian approximation. Recently, sketching curvature for OOD detection (SCOD) [15] makes it efficient and effective by using the local sketched curvature (Hessian/Fisher) of DNN models as a bridge. Specifically, they measure the final uncertainty based on both the uncertainty of the model parameters and the influence of input samples on the DNN models. In particular, however, since a plethora of approximations is applied in the process, and the influence of an input sample on DNN models can hardly be estimated stably, we observe that there are deviations in the estimated uncertainty for a certain number of input samples.
To resolve the above issue, we propose a novel AdvSCOD framework that estimates the uncertainty for each input sample by aggregating that of a small set of samples in its neighborhood. In particular, inspired by the fact that adversarial attacks that show imperceptible perturbation can lead DNN models to make totally different predictions, we enrich the input sample by applying adversarial perturbation to it, which we believe will better reflect the influence of the input sample on DNN models. Extensive experiments validate how our proposed AdvSCOD outperforms the state-of-the-art Bayesian-based methods on OOD detection. Furthermore, we also experimentally demonstrate that adversarial perturbation is better than several other types of perturbation.
Overall, our key contributions are summarized as follows:
  • We propose a novel AdvSCOD framework that estimates the uncertainty of each input sample by aggregating its small neighborhoods.
  • We conduct extensive experiments to validate the effectiveness of AdvSCOD and its superiority to state-of-the-art Bayesian-based OOD detection methods.
  • We provide a new perspective on evaluating the sample’s influence on DNN models in view of adversarial attacks.

2. Related Work

2.1. OOD Detection

The most common solution for handling the OOD overconfidence issue of DNN models [7] is to conduct OOD detection, i.e., detecting and then rejecting OOD inputs. According to the presence or absence of label information, existing OOD detection approaches can be broadly divided into two categories: generative-based and discriminative-based.
Generative-based methods aim to model the distribution of the training dataset, e.g., by using auto-encoder [16], flow-based models [17], and autoregressive models [18,19], and thus the estimation of the likelihood of given inputs can be measured by distribution shift. Indeed, it is intuitive that the likelihood of the in-distribution (ID) samples should be higher than that of the OOD samples. However, since current generative models tend to overfit the training set, many recent works show that they are not robust in OOD detection [20]. Discriminative-based methods instead conduct OOD detection utilizing the label information. Hendrycks et al. [9] observed that using the simple maximum softmax probabilities (MSP) of DNN classifiers is sufficient for differentiating ID and OOD samples. Later, researchers further improved OOD detection by utilizing temperature scaling and adding small perturbations [10], Mahalanobis distance [11], energy-based models [12,21,22,23,24], logit normalization [13], etc. For a more complete review of OOD detection, please refer to the survey paper [25]. Different from what has been thoroughly explored, we investigate in an orthogonal direction, i.e., by employing Bayesian models.

2.2. Bayesian-Based OOD Detection

Since Bayesian approximation is powerful in characterizing epistemic uncertainty in DNNs, it is promising in handling the OOD detection task. However, Bayesian methods traditionally rely on Monte Carlo [26] or variational inference [27,28,29] and thus are not suitable for pre-trained DNNs. Therefore, current researchers instead apply the Laplace approximation to the Bayesian posterior [30], even though it requires estimating the curvature of DNNs, which is very time-consuming. Sketching curvature for OOD detection (SCOD) [15] uses the Fisher information matrix to approximate the Hessian matrix, making the process efficient. Instead of calculating the uncertainty of DNNs with a single input sample as in SCOD, we further enrich it by applying adversarial perturbations and thus making the estimation more robust.

2.3. Sample Enrichment and Adversarial Attack

Sample enrichment, or data augmentation, is widely adopted for preventing DNN models from overfitting by synthesizing label-preserving images [31,32]. It can be realized by applying random crop, padding, flipping, rotating, scaling, etc. Another type of sample enrichment adds adversarial perturbation to the training images, aiming at improving the adversarial robustness [33]. We leverage the idea of adversarial perturbation to achieve sample enrichment, which aims to make the estimation of uncertainty more accurate.
Another related direction to ours is adversarial attack [33,34,35,36,37,38], whose purpose is to apply imperceptible perturbation to mislead DNN classifiers. In contrast, we apply adversarial perturbation to the input sample to enrich it for better evaluating the influence on the DNN models.

3. Background and Problem Formulation

3.1. Problem Statement of OOD Detection

We formulate the problem in the context of image classification with DNNs. Given a DNN classifier f θ trained on the dataset D with pairs of images and their corresponding labels { ( x i , y i ) i = 1 , , M } , where x i R d and y i { 1 , 2 , , K } and θ represents the parameters of f, we aim to define a measurement that can determine whether an input image x R d belongs to the ID or OOD samples by using f θ .

3.2. Bayesian Neural Networks and OOD Detection

Probabilistic DNN. The DNN classifier f θ can be considered as a probabilistic model P ( y x , θ ) . Given an input image x, the classifier f outputs o using weights θ ,
o = f θ ( x ) ,
where o is the predicted logit, and then a distributional family P maps o to a distribution over the targets, i.e., P ( y ) ,
P ( y ) = P ( o )
In this view, we can learn the weights θ by maximum likelihood (MLE) estimation,
θ MLE = arg max θ log P ( D θ ) = arg max θ log P y i x i , θ
By giving a prior of θ , it further becomes a maximum posterior estimate (MAP),
θ MAP = arg max θ log P ( θ D ) = arg max θ log P ( D θ ) + log P ( θ )
Bayesian Neural Networks. Instead of estimating a single optimal point as in Equation (4), Bayesian neural networks (BNN) find the posterior distribution P ( θ D ) of the parameter θ and thus introduce uncertainty in the prediction.
Formally, the predictive distribution of an unknown label y of a test data item x is given by
P ( y x ) = E P ( θ D ) [ P ( y x , θ ) ]
However, directly calculating the above equation is usually intractable. Therefore, researchers usually use Laplace approximation to estimate the distribution P ( θ D ) and use Monte Carlo sampling to calculate the final expected value.
BNN-based OOD Detection. Many recent works show that the uncertainty of BNN can be utilized for OOD detection, since the predictions on ID and OOD samples have different uncertainties [39,40,41,42,43].
Suppose the prior of θ follows a Gaussian distribution with a standard deviation of σ ; the Laplace posterior of the variance of θ can be calculated by
Σ = 1 2 ( H L + 1 2 σ 2 I ) 1
where H L is the Hessian matrix with respect to the parameters of the pretrained DNN classifier f, i.e., θ , and I is an identity matrix. Therefore, we could utilize Σ to measure the uncertainty of DNNs, so as to conduct OOD detection [23,44].
However, for complex DNN models, calculating this exact Bayesian posterior approximation can still be challenging, where estimating and inversing huge matrices to calculate σ is demanded.

3.3. SCOD [15]

The framework of sketching curvature for OOD Detection (SCOD) estimates the uncertainty in two respects: (1) the uncertainty of the model parameters on the prediction and (2) the influence of input samples on the DNN models.
For the uncertainty of the model parameters, SCOD re-estimates the variance of parameters by replacing the Hessian matrix in Equation (6) with the Fisher information matrix, whose calculation is more efficient and numerically stable,
Σ * = 1 2 1 M F θ * ( x i ) + 1 2 ε 2 I 1 ,
where F θ * ( x i ) denotes the weight-space Fisher evaluated for a particular input x i and the trained weights θ * , which is calculated by
F θ * ( x i ) = J o , θ * F o ( o ) J o , θ * ,
with J o , θ * denoting the Jacobian matrix evaluated for data x i under the parameter θ * . That is, J o , θ * [ i , j ] = f i / θ j * . Note that the process of estimating the uncertainty can be conducted offline.
As for the influence of input samples, i.e., the uncertainty determined by the certain input sample x, we directly measure it using Equation (8), that is, F θ * ( x ) . Note that this process is conducted online.
Therefore, the final uncertainty can be calculated as follows,
Unc x = Tr F θ * Σ * ,
where Tr ( · ) calculates the trace. Note that, although the calculation of Hessian matrix is much more efficient than the original Fisher matrix, SCOD further accelerates the process by splitting the original matrix into smaller ones. Since it is not the focus of this paper, we refer the reader to the original SCOD paper [15].
Discussion and Our Solution However, since lots of information is discarded in the approximation, the calculated Fisher information matrix may not be that accurate. Furthermore, as reported in the field of adversarial attacks, a slight change in the input image can lead the classifier to make a totally different prediction. In that case, the estimation of J o , θ * is also quite unstable. Both factors make the calculated uncertainty inaccurate.
To handle the above issues, we propose utilizing the averaged uncertainty calculated together with an enriched sample set in its small neighborhood, instead of using the value evaluated on a single one. In particular, since applying an adversarial attack is expected to bring about the largest deviation in J o , θ * , we choose the enriched sample set obtained by applying adversarial perturbation.

4. Method

In this section, we propose a simple OOD detection framework with sketching curvature and adversarial sample enrichment (AdvSCOD). The framework consists of two key steps: sample enrichment via adversarial perturbation, and uncertainty averaging with enriched samples. Please refer to Figure 1 and Algorithm 1 for demonstration.
Algorithm 1 AdvSCOD
1:
Input: f θ ( · ) ; ▹ A pre-trained DNN model
2:
Unc ( · ) ; ▹ A SCOD function to calculate Uncertainty
3:
x  ; ▹ The input sample
4:
λ , T , α ; ▹ Hyperparameters
5:
Output: Unc + ▹ An enhanced Unc value for input x
6:
x 0 = x ;
7:
for  t 1 to T do
8:
x t + 1 = Π x + S x t + α sgn x L ( θ , x , y ) ; ▹ PGD attack
9:
E ( x ) . a p p e n d ( x t + 1 ) ;
10:
end for
11:
Unc + ( x ) = Unc ( x ) + λ × x E ( x ) Unc ( x ) ;
12:
return Unc + ( x )

4.1. Sample Enrichment via Adversarial Perturbation

To enrich the input sample x, we propose applying adversarial perturbation on x, which is imperceptible for humans, and thus will not introduce any semantic shifts. That is, the samples after applying perturbation have the same ID/OOD property as the original input sample x. Specifically, we choose the popular iterative-based projected gradient descent (PGD) [33],
x t + 1 = C l i p x , ϵ ( Π x + S x t + α sign x L ( θ , x , y ) )
where y is the predicted category made by the DNN classifier f θ on the sample x, L ( θ , x , y ) is the loss function, i.e., cross-entropy loss, for f θ , S R d is the manipulative power of the adversary defined by a l -ball with radius ϵ , t is the iteration, α is the step size, and sign ( · ) is the direction function.
Therefore, after T iterations of PGD, we finally obtain an enriched sample set E ( x ) = { x 1 , , x T } .

4.2. Uncertainty Averaging with Enriched Samples

Given x and the enriched sample set E ( x ) = { x 1 , , x T } , we calculate the final uncertainty simply by averaging the Unc value measured by SCOD,
Unc + ( x ) = Unc ( x ) + λ × x E ( x ) Unc ( x )
where λ is a hyperparameter that is empirically set to 0.01.

5. Experimental Results

5.1. Implementation

We implement our AdvSCOD framework and reproduce all the OOD detection methods mentioned above with PyTorch and report the results executed on a workstation with an Intel Xeon E5-2678 [email protected] Hz and 64 GB of memory using a single RTX 2080Ti GPU. For AdvSCOD, we set the number of adversarial samples T = 25 . For other OOD detection methods, we follow the settings in their original papers.

5.2. Experimental Setup

5.2.1. DNN Classifier and Datasets

For the DNN classifiers, we choose the popular GoogLeNet [45] on the datasets with color images, e.g., CIFAR-10, CIFAR-100, and SVHN, and LeNet [46] on the datasets with gray images, e.g., MNIST and Fashion. We convert color images to gray images, when evaluating using LeNet, and vice versa.

5.2.2. Perturbation Solutions

We adopted three perturbation methods, including two adversarial perturbations, i.e., PGD [33] and FGSM [47], and one Gaussian perturbation. FGSM is a one-step adversarial attack method by which we generate a series of perturbated samples via adjusting the amplitude. For PGD, we consider all the intermediate samples generated during the attack as perturbated samples. For the Gaussian perturbation, we collected perturbated samples by applying different intensities of Gaussian noise. Specifically, we set α = 0.0002 , l bound ϵ = 0.01 in PGD perturbation for the experiments on SVHN, CIFAR10, and CIFAR100, and α = 0.002 , ϵ = 0.1 for the experiments on MNIST and Fashion. For the perturbation amplitude in FGSM and Gaussian perturbation, we set the range between 0 and 0.05 on SVHN, CIFAR10, and CIFAR100, and we set the range between 0 and 0.2 for MNIST and Fashion. The mean and variance of Gaussian perturbation are set to 0 and 1, respectively.

5.2.3. Baseline OOD Detection Solutions

We compared our proposed AdvSCOD with four state-of-the-art Bayesian-based OOD detection solutions, i.e., Naive [40], KFAC Laplace [48], Local Ensembles [44], and SCOD [15]. Naive produces a measure of uncertainty directly from the output of the pretrained model. The KFAC Laplace and Local Ensembles are similar to ours, with both using the curvature of the model to enhance the pretrained model for uncertainty estimation. Even though KFAC Laplace also relies on Laplace approximation, it uses different approximation methods to approximate the results of the Hessian matrix. Local Ensembles instead uses local second-order information to approximate the variance of prediction results across an ensemble of models from the same class.

5.2.4. Evaluation Metrics

To evaluate the performance of OOD detection, we adopted two commonly used metrics: AUROC and FPR95 following [9]. AUROC represents the area under the precise recall curve, and a larger value of the AUROC indicates better OOD detection performance. FPR95 represents the false positive rate of OOD examples when true positive rate of in-distribution examples is at 95%, which is better with lower values. Specifically, since better AUROC and FPR95 results are obtained if the OOD dataset has higher complexity than the ID one, we also adopted two other metrics, i.e., AUROC a v g and FPR95 a v g , which are the average values of AUROC and FRP95 with flipped settings of ID and OOD.

5.3. Performance Comparison and Analysis

5.3.1. Comparison of Our Results with The State-Of-The-Art Methods

We compare AdvSCOD with three state-of-the-art Bayesian-based OOD detection solutions, i.e., Local Ensembles, KFAC Laplace, Naive, and SCOD. The results reported in Table 1, Table 2, Table 3 and Table 4 show that AdvSCOD outperforms the four state-of-the-art solutions in all cases with different settings of ID and OOD datasets under both AUROC and FRP95 metrics. In particular, we would like to highlight that the AUROC performance of AdvSCOD is improved by at least 0.01, and the FPR95 value is decreased by nearly 0.01, compared with SCOD, which is evaluated on each single sample. Therefore, we conclude that our solution, which enriches adversarial samples for uncertainty estimation, is effective in practice.

5.3.2. How Perturbation Affects Uncertainty

To validate our assumption that SCOD may be unstable, we re-calculate the uncertainty using SCOD on images that are under perturbation. Instead of reporting the results of all the images, we choose those samples that have original wrong OOD detection results using SCOD, such that the instability of calculated uncertainty can be better demonstrated. Furthermore, we choose three different types of perturbation, with two adversarial perturbation, i.e., PGD and FGSM, and one Gaussian noise-based perturbation.
The results are depicted in Figure 2. It can be seen that, although the uncertainty of these OOD samples is very low under the original SCOD measurement, it will be sharply enlarged after applying adversarial perturbation. On the contrary, the uncertainty of ID samples under the SCOD measurement drops. This trend continues when the perturbation amplitude increases, and the newly calculated uncertainty of OOD samples soon surpasses that of ID samples. Although the uncertainty slightly drops when the applied perturbation amplitude is a bit large, we could see that the uncertainty of OOD samples is always larger than that of ID samples. By contrast, although the uncertainty of OOD samples will be also enlarged with Gaussian perturbation applied, it is still significantly lower than that of ID samples. Therefore, we can conclude that applying adversarial perturbation on the samples is a good way to differentiate ID and OOD samples under the SCOD measurement.

5.3.3. Comparison of Different Perturbations

Since the trend of the SCOD uncertainty with applying perturbation is expected to be helpful in differentiating ID and OOD samples as shown in Figure 2, we compare the OOD detection performance of AdvSCOD with three different kinds of perturbation. Specifically, we illustrate the distribution of uncertainty scores of ID samples, i.e., SVHN, and OOD samples, i.e., CIFAR10 and CIFAR100, with and without the application of perturbation, as shown in Figure 3.
The results in Figure 3 show that the distribution of uncertainty scores only changes very slightly after Gaussian perturbation is applied, while the changes after applying both adversarial perturbations are quite obvious. Indeed, compared with the original distributions, the distributions of ID and OOD samples after the application of adversarial perturbation are much more separated, indicating that it is easier to differentiate them. In particular, the degree of separation with the application of PGD perturbation is a bit larger.
To better demonstrate which type of perturbation is more suitable for AdvSCOD in conducting OOD detection, we also report quantitative experimental results in Table 5 and Table 6. It can be seen that AdvSCOD with PGD perturbation is the best under both the AUROC and FPR95 metrics. AdvSCOD with FGSM perturbation is the second best and outperforms AdvSCOD with Gaussian perturbation in most cases. Therefore, we choose PGD perturbation in our AdvSCOD framework.

5.3.4. Evaluation on Large-Scale Datasets

We also report the OOD detection performance of AdvSCOD evaluated with large-scale datasets, e.g., SUN [49] and iNaturalist [50], as OOD. The results reported in Table 7 show that AdvSCOD performs the best, and the values are comparable to those evaluated on small-scale datasets, validating the claim that SCOD is scalable to large-scale datasets.

5.3.5. Parameter Tuning Experiments

In this section, we evaluate the OOD performance of AdvSCOD with different values of hyper-parameters, e.g., α and λ .
The results reported in Table 8 show that the performance slightly changes if we enlarge or decrease the value of α , but the results are almost the best with current settings of α . Therefore, we choose these α values, e.g., 0.0002 in SVHN, CIFAR10 and CIFAR100, and 0.002 in MNIST and Fashion.
The results reported in Table 9 show that the performance only slightly changes with different values of λ . In particular, the performance is the best with λ = 0.01 . Therefore, we set λ to 0.01 in the experiments.

6. Conclusions

In this paper, we have proposed a novel Bayesian-based AdvSCOD framework for robust OOD detection. It is derived from our observation that the uncertainty estimated by SCOD is not robust, since there is a lot of approximation and the influence of the input samples on DNN models can hardly be measured stably. Inspired by the fact adversarial attacks that show imperceptible perturbation can affect the prediction of DNN models significantly, we propose enriching the input sample with those in its neighborhood generated by applying adversarial perturbation, which we believe can better reflect the influence on model predictions, and then we average their uncertainties. Extensive experiments validate the effectiveness of AdvSCOD and its superiority to the state-of-the-art Bayesian-based OOD detection solutions. We hope that our work can inspire more research on handling OOD detection in a more explainable Bayesian view.
Limitation and Future Work Due to the complexity of Bayesian-based methods in sketching curvature, we found that our AdvSCOD is quite slow when the ID dataset is large. In the future, we plan to accelerate AdvSCOD by handling more difficult and large-scale settings.

Author Contributions

Conceptualization, K.T.;methodology, K.T. and J.Q.; software, J.Q.; validation, J.Q.; formal analysis, K.T. and J.Q.; investigation, K.T. and J.Q.; writing—original draft preparation, K.T. and J.Q.; writing—review and editing, K.T., J.Q., P.Z. and C.Z. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported in part by the National Key Research and Development Project of China (2020AAA0107704), the National Natural Science Foundation of China (62102105, 62073263), the Science and Technology Program of Guangzhou (202002030263, 202102010419, and 202201020229), the Guangdong Basic and Applied Basic Research Foundation (2020A1515110997, 2022A1515011501, and 2022A1515010138).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Any data used to support the findings of this study are from previously reported studies and datasets, which have been cited.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. LeCun, Y.; Bengio, Y.; Hinton, G. Deep learning. Nature 2015, 521, 436–444. [Google Scholar] [CrossRef] [PubMed]
  2. He, K.; Zhang, X.; Ren, S.; Sun, J. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA, 27–30 June 2016; pp. 770–778. [Google Scholar]
  3. Tang, K.; Ma, Y.; Miao, D.; Song, P.; Gu, Z.; Tian, Z.; Wang, W. Decision fusion networks for image classification. IEEE Trans. Neural Netw. Learn. Syst. 2022. [Google Scholar] [CrossRef] [PubMed]
  4. Simonyan, K.; Zisserman, A. Very Deep Convolutional Networks for Large-Scale Image Recognition. In Proceedings of the International Conference on Learning Representations, San Diego, CA, USA, 7–9 May 2015. [Google Scholar]
  5. Bendale, A.; Boult, T. Towards open world recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Boston, MA, USA, 7–12 June 2015; pp. 1893–1902. [Google Scholar]
  6. Nguyen, A.; Yosinski, J.; Clune, J. Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Boston, MA, USA, 8–10 June 2015; pp. 427–436. [Google Scholar]
  7. Hein, M.; Andriushchenko, M.; Bitterwolf, J. 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, Long Beach, CA, USA, 16–20 June 2019; pp. 41–50. [Google Scholar]
  8. Tang, K.; Miao, D.; Peng, W.; Wu, J.; Shi, Y.; Gu, Z.; Tian, Z.; Wang, W. CODEs: Chamfer Out-of-Distribution Examples against Overconfidence Issue. In Proceedings of the IEEE/CVF International Conference on Computer Vision, Long Beach, CA, USA, 15–20 June 2021; pp. 1153–1162. [Google Scholar]
  9. Hendrycks, D.; Gimpel, K. A baseline for detecting misclassified and out-of-distribution examples in neural networks. arXiv 2016, arXiv:1610.02136. [Google Scholar]
  10. Liang, S.; Li, Y.; Srikant, R. Enhancing the reliability of out-of-distribution image detection in neural networks. arXiv 2017, arXiv:1706.02690. [Google Scholar]
  11. Lee, K.; Lee, K.; Lee, H.; Shin, J. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. Adv. Neural Inf. Process. Syst. 2018, 31, 7167–7177. [Google Scholar]
  12. Liu, W.; Wang, X.; Owens, J.; Li, Y. Energy-based out-of-distribution detection. Adv. Neural Inf. Process. Syst. 2020, 33, 21464–21475. [Google Scholar]
  13. Wei, H.; Xie, R.; Cheng, H.; Feng, L.; An, B.; Li, Y. Mitigating Neural Network Overconfidence with Logit Normalization. In Proceedings of the International Conference on Machine Learning, Baltimore, MD, USA, 17–23 July 2022. [Google Scholar]
  14. Kim, K.; Shin, J.; Kim, H. Locally Most Powerful Bayesian Test for Out-of-Distribution Detection using Deep Generative Models. Adv. Neural Inf. Process. Syst. 2021, 34, 14913–14924. [Google Scholar]
  15. Sharma, A.; Azizan, N.; Pavone, M. Sketching curvature for efficient out-of-distribution detection for deep neural networks. In Proceedings of the Uncertainty in Artificial Intelligence, PMLR, Virtual Event, 27–30 July 2021; pp. 1958–1967. [Google Scholar]
  16. Kingma, D.P.; Welling, M. Auto-encoding variational bayes. arXiv 2013, arXiv:1312.6114. [Google Scholar]
  17. Rezende, D.; Mohamed, S. Variational inference with normalizing flows. In Proceedings of the International Conference on Machine Learning, PMLR, Lille, France, 7–9 July 2015; pp. 1530–1538. [Google Scholar]
  18. Van den Oord, A.; Kalchbrenner, N.; Espeholt, L.; Vinyals, O.; Graves, A. Conditional image generation with pixelcnn decoders. Adv. Neural Inf. Process. Syst. 2016, 29, 4790–4798. [Google Scholar]
  19. Salimans, T.; Karpathy, A.; Chen, X.; Kingma, D.P. Pixelcnn++: Improving the pixelcnn with discretized logistic mixture likelihood and other modifications. arXiv 2017, arXiv:1701.05517. [Google Scholar]
  20. Nalisnick, E.; Matsukawa, A.; Teh, Y.W.; Gorur, D.; Lakshminarayanan, B. Do Deep Generative Models Know What They Do not Know? In Proceedings of the International Conference on Learning Representations, New Orleans, LA, USA, 6–9 May 2019. [Google Scholar]
  21. Lin, Z.; Roy, S.D.; Li, Y. Mood: Multi-level out-of-distribution detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Nashville, TN, USA, 20–25 June 2021; pp. 15313–15323. [Google Scholar]
  22. Morteza, P.; Li, Y. Provable guarantees for understanding out-of-distribution detection. In Proceedings of the AAAI Conference on Artificial Intelligence, Virtual, 22 February–1 March 2022; Volume 8. [Google Scholar]
  23. Wang, H.; Liu, W.; Bocchieri, A.; Li, Y. Can multi-label classification networks know what they don’t know? Adv. Neural Inf. Process. Syst. 2021, 34, 29074–29087. [Google Scholar]
  24. Sun, Y.; Guo, C.; Li, Y. React: Out-of-distribution detection with rectified activations. Adv. Neural Inf. Process. Syst. 2021, 34, 144–157. [Google Scholar]
  25. Yang, J.; Zhou, K.; Li, Y.; Liu, Z. Generalized out-of-distribution detection: A survey. arXiv 2021, arXiv:2110.11334. [Google Scholar]
  26. Neal, R.M. Bayesian Learning for Neural Networks; Springer Science & Business Media: Berlin/Heidelberg, Germany, 2012; Volume 118. [Google Scholar]
  27. Graves, A. Practical variational inference for neural networks. Adv. Neural Inf. Process. Syst. 2011, 24, 2348–2356. [Google Scholar]
  28. Blundell, C.; Cornebise, J.; Kavukcuoglu, K.; Wierstra, D. Weight uncertainty in neural network. In Proceedings of the International Conference on Machine Learning, PMLR, Lille, France, 6 July–11 July 2015; pp. 1613–1622. [Google Scholar]
  29. Liu, Q.; Wang, D. Stein variational gradient descent: A general purpose bayesian inference algorithm. Adv. Neural Inf. Process. Syst. 2016, 29, 2370–2378. [Google Scholar]
  30. MacKay, D.J. A practical Bayesian framework for backpropagation networks. Neural Comput. 1992, 4, 448–472. [Google Scholar] [CrossRef] [Green Version]
  31. Krizhevsky, A.; Sutskever, I.; Hinton, G.E. ImageNet Classification with Deep Convolutional Neural Networks. In Proceedings of the Advances in Neural Information Processing Systems, Lake Tahoe, NV, USA, 3–6 December 2012; Pereira, F., Burges, C., Bottou, L., Weinberger, K., Eds.; Curran Associates, Inc.: Red Hook, NY, USA, 2012; Volume 25. [Google Scholar]
  32. Cubuk, E.D.; Zoph, B.; Shlens, J.; Le, Q.V. Randaugment: Practical automated data augmentation with a reduced search space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, Seattle, WA, USA, 14–19 June 2020; pp. 702–703. [Google Scholar]
  33. Madry, A.; Makelov, A.; Schmidt, L.; Tsipras, D.; Vladu, A. Towards Deep Learning Models Resistant to Adversarial Attacks. In Proceedings of the International Conference on Learning Representations, Vancouver, BC, Canada, 30 April–3 May 2018. [Google Scholar]
  34. Ren, K.; Zheng, T.; Qin, Z.; Liu, X. Adversarial attacks and defenses in deep learning. Engineering 2020, 6, 346–360. [Google Scholar] [CrossRef]
  35. Yuan, X.; He, P.; Zhu, Q.; Li, X. Adversarial examples: Attacks and defenses for deep learning. IEEE Trans. Neural Netw. Learn. Syst. 2019, 30, 2805–2824. [Google Scholar] [CrossRef] [Green Version]
  36. Tang, K.; Shi, Y.; Lou, T.; Peng, W.; He, X.; Zhu, P.; Gu, Z.; Tian, Z. Rethinking Perturbation Directions for Imperceptible Adversarial Attacks on Point Clouds. IEEE Internet Things J. 2022. [Google Scholar] [CrossRef]
  37. Tang, K.; Shi, Y.; Wu, J.; Peng, W.; Khan, A.; Zhu, P.; Gu, Z. NormalAttack: Curvature-Aware Shape Deformation along Normals for Imperceptible Point Cloud Attack. Secur. Commun. Netw. 2022, 2022, 1186633. [Google Scholar] [CrossRef]
  38. Hong, J.; Tang, K.; Gao, C.; Wang, S.; Guo, S.; Zhu, P. GM-Attack: Improving the Transferability of Adversarial Attacks. In Proceedings of the International Conference on Knowledge Science, Engineering and Management, Singapore, 6–8 August 2022; Springer: Berlin/Heidelberg, Germany, 2022; pp. 489–500. [Google Scholar]
  39. Gal, Y.; Ghahramani, Z. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In Proceedings of the International Conference on Machine Learning, PMLR, New York, NY, USA, 20–22 June 2016; pp. 1050–1059. [Google Scholar]
  40. Lakshminarayanan, B.; Pritzel, A.; Blundell, C. Simple and scalable predictive uncertainty estimation using deep ensembles. Adv. Neural Inf. Process. Syst. 2017, 30, 6402–6413. [Google Scholar]
  41. Osawa, K.; Swaroop, S.; Khan, M.E.E.; Jain, A.; Eschenhagen, R.; Turner, R.E.; Yokota, R. Practical deep learning with Bayesian principles. Adv. Neural Inf. Process. Syst. 2019, 32, 4289–4301. [Google Scholar]
  42. Malinin, A.; Gales, M. Predictive uncertainty estimation via prior networks. Adv. Neural Inf. Process. Syst. 2018, 31, 7047–7058. [Google Scholar]
  43. Malinin, A.; Gales, M. Reverse kl-divergence training of prior networks: Improved uncertainty and adversarial robustness. Adv. Neural Inf. Process. Syst. 2019, 32, 14520–14531. [Google Scholar]
  44. Madras, D.; Atwood, J.; D’Amour, A. Detecting extrapolation with local ensembles. arXiv 2019, arXiv:1910.09573. [Google Scholar]
  45. Szegedy, C.; Liu, W.; Jia, Y.; Sermanet, P.; Reed, S.; Anguelov, D.; Erhan, D.; Vanhoucke, V.; Rabinovich, A. Going deeper with convolutions. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Boston, MA, USA, 7–12 June 2015; pp. 1–9. [Google Scholar]
  46. LeCun, Y.; Bottou, L.; Bengio, Y.; Haffner, P. Gradient-based learning applied to document recognition. Proc. IEEE 1998, 86, 2278–2324. [Google Scholar] [CrossRef] [Green Version]
  47. Goodfellow, I.J.; Shlens, J.; Szegedy, C. Explaining and harnessing adversarial examples. arXiv 2014, arXiv:1412.6572. [Google Scholar]
  48. Ritter, H.; Botev, A.; Barber, D. A scalable laplace approximation for neural networks. In Proceedings of the 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, 30 April–3 May 2018; Volume 6. [Google Scholar]
  49. Xiao, J.; Hays, J.; Ehinger, K.A.; Oliva, A.; Torralba, A. Sun database: Large-scale scene recognition from abbey to zoo. In Proceedings of the 2010 IEEE Computer Society Conference on Computer Vision and Pattern Recognition, San Francisco, CA, USA, 13–18 June 2010; pp. 3485–3492. [Google Scholar]
  50. Van Horn, G.; Mac Aodha, O.; Song, Y.; Cui, Y.; Sun, C.; Shepard, A.; Adam, H.; Perona, P.; Belongie, S. The inaturalist species classification and detection dataset. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018; pp. 8769–8778. [Google Scholar]
Figure 1. Demonstration of the AdvSCOD framework.
Figure 1. Demonstration of the AdvSCOD framework.
Mathematics 11 00692 g001
Figure 2. The trends of uncertainly calculation of the samples that have been misclassified by SOCD when applying different types of perturbation. We used SVHN as the ID dataset and CIFAR10 and CIFAR100 as the OOD datasets.
Figure 2. The trends of uncertainly calculation of the samples that have been misclassified by SOCD when applying different types of perturbation. We used SVHN as the ID dataset and CIFAR10 and CIFAR100 as the OOD datasets.
Mathematics 11 00692 g002
Figure 3. The distribution of uncertainty calculated on samples with the application of different types of perturbations. We use SVHN as the ID dataset and CIFAR10 and CIFAR100 as the OOD datasets.
Figure 3. The distribution of uncertainty calculated on samples with the application of different types of perturbations. We use SVHN as the ID dataset and CIFAR10 and CIFAR100 as the OOD datasets.
Mathematics 11 00692 g003
Table 1. Comparison of the OOD detection performance measured by AUROC (larger values are better). Bold numbers are superior results.
Table 1. Comparison of the OOD detection performance measured by AUROC (larger values are better). Bold numbers are superior results.
IDOODLocal EnsemblesKFAC LaplaceNaiveSCODAdvSCOD
SVHNCIFAR100.93710.94830.94800.95730.9668
CIFAR1000.94230.94620.94610.94560.9538
MNIST0.73790.78310.79100.77690.7568
Fashion0.93640.94260.93750.93910.9441
CIFAR10SVHN0.91980.92300.92350.92240.9358
CIFAR1000.87660.87880.87870.87680.8830
MNIST0.87270.86310.87470.86600.9281
Fashion0.93710.86340.87400.91060.9473
CIFAR100SVHN0.80470.81020.77790.82240.8323
CIFAR100.79510.81150.77250.80710.8136
MNIST0.70860.74030.71110.73560.7512
Fashion0.88840.92260.90030.91790.9208
MNISTSVHN0.96010.94540.97960.97980.9870
CIFAR100.95750.94590.95950.97670.9861
CIFAR1000.96920.96340.96850.98300.9900
Fashion0.94170.93730.93750.95540.9714
FashionSVHN0.96730.96540.99410.97680.9790
CIFAR100.95750.94590.97070.98100.9840
CIFAR1000.96920.98060.97390.97900.9824
MNIST0.80560.83470.78240.88760.9696
Table 2. Comparison of the OOD detection performance measured by AUROC a v g . Bold numbers are superior results.
Table 2. Comparison of the OOD detection performance measured by AUROC a v g . Bold numbers are superior results.
Dataset PairLocal EnsemblesKFAC LaplaceNaiveSCODAdvSCOD
(SVHN,CIFAR10)0.92840.93570.93570.93990.9513
(SVHN,CIFAR100)0.87350.87820.86200.88400.8931
(SVHN,MNIST)0.84900.86420.88530.87830.8719
(SVHN,Fashion)0.95190.95400.96580.95800.9616
(CIFAR10,CIFAR100)0.83580.84520.82560.84190.8483
(CIFAR10,MNIST)0.91510.90450.91710.92140.9571
(CIFAR10,Fashion)0.94730.90460.92240.94580.9657
(CIFAR100,MNIST)0.83890.85180.83980.85930.8706
(CIFAR100,Fashion)0.92880.95160.93710.94850.9516
(MNIST,Fashion)0.87370.88600.85990.92150.9705
Table 3. Comparison of the OOD detection performance measured by FPR95 (lower value is better). Bold numbers are superior results.
Table 3. Comparison of the OOD detection performance measured by FPR95 (lower value is better). Bold numbers are superior results.
IDOODLocal EnsemblesKFAC LaplaceNaiveSCODAdvSCOD
SVHNCIFAR100.18720.19230.19280.14640.1417
CIFAR1000.19920.19520.19570.16820.1596
MNIST0.80370.80110.70560.77740.7941
Fashion0.27230.21840.26850.26040.1841
CIFAR10SVHN0.22780.23600.23480.22610.2221
CIFAR1000.39050.38960.39140.38460.3706
MNIST0.42820.41810.38750.42130.2633
Fashion0.40850.41810.38950.27350.1867
CIFAR100SVHN0.61180.59800.62060.52330.4872
CIFAR100.57660.57420.63130.55180.5039
MNIST0.62060.62180.65660.62960.6034
Fashion0.43740.29360.36530.31730.2868
MNISTSVHN0.14360.13340.08360.06350.0501
CIFAR100.18070.16390.16360.09900.0706
CIFAR1000.17720.19920.13640.07680.0495
Fashion0.27670.25210.25240.19990.1211
FashionSVHN0.06030.07120.02260.05860.0503
CIFAR100.07330.06920.07780.06120.0406
CIFAR1000.07570.07330.08150.06850.0516
MNIST0.51160.40780.49440.43560.1831
Table 4. Comparison of the OOD detection performance measured by FPR95 a v g . Bold numbers are superior results.
Table 4. Comparison of the OOD detection performance measured by FPR95 a v g . Bold numbers are superior results.
Dataset PairLocal EnsemblesKFAC LaplaceNaiveSCODAdvSCOD
(SVHN,CIFAR10)0.20750.21420.21380.18620.1819
(SVHN,CIFAR100)0.40550.39660.40820.34580.3234
(SVHN,MNIST)0.47370.46720.39460.42040.4221
(SVHN,Fashion)0.16630.14480.14560.15950.1172
(CIFAR10,CIFAR100)0.48360.48190.51130.46820.4373
(CIFAR10,MNIST)0.30440.29100.27560.26010.1669
(CIFAR10,Fashion)0.24090.24370.23360.16730.1137
(CIFAR100,MNIST)0.39890.41050.39650.35320.3265
(CIFAR100,Fashion)0.25660.18350.22340.19290.1692
(MNIST,Fashion)0.39420.32990.37340.31770.1521
Table 5. Comparison of the OOD detection performance of AdvSCOD with different types of perturbation. The values on the left side and right side of “/” are the results measured by AUROC and FPR95, respectively. Bold numbers are superior results.
Table 5. Comparison of the OOD detection performance of AdvSCOD with different types of perturbation. The values on the left side and right side of “/” are the results measured by AUROC and FPR95, respectively. Bold numbers are superior results.
IDOODFGSMGaussianPGD
SVHNCIFAR100.9597/0.13980.9571/0.14350.9635/0.1417
CIFAR1000.9508/0.16810.9463/0.16510.9538/0.1596
MNIST0.7613/0.79260.7746/0.77700.7568/0.7941
Fashion0.9389/0.28180.9391/0.26040.9441/0.1841
CIFAR10SVHN0.9334/0.22340.9229/0.22550.9358/0.2221
CIFAR1000.8779/0.37400.8777/0.37760.8830/0.3706
MNIST0.8874/0.40350.8667/0.42110.9281/0.2633
Fashion0.9364/0.23390.9104/0.27350.9473/0.1867
CIFAR100SVHN0.8304/0.50390.8221/0.52320.8323/0.4872
CIFAR100.8116/0.53270.8073/0.55240.8136/0.5039
MNIST0.7481/0.61170.7356/0.62980.7512/0.6034
Fashion0.9206/0.30710.9159/0.31680.9208/0.2868
MNISTSVHN0.9829/0.06250.9801/0.06340.9870/0.0501
CIFAR100.9862/0.06550.9770/0.09820.9861/0.0706
CIFAR1000.9899/0.05120.9833/0.07520.9900/0.0495
Fashion0.9613/0.15400.9557/0.18180.9714/0.1211
FashionSVHN0.9778/0.05220.9768/0.05880.9790/0.0503
CIFAR100.9823/0.04670.9810/0.06120.9840/0.0406
CIFAR1000.9797/0.05300.9788/0.06820.9824/0.0516
MNIST0.9566/0.30240.8871/0.43560.9696/0.1831
Table 6. Comparison of the OOD detection performance of AdvSCOD measured by AUROC a v g /FPR95 a v g with different types of perturbation. Bold numbers are superior results.
Table 6. Comparison of the OOD detection performance of AdvSCOD measured by AUROC a v g /FPR95 a v g with different types of perturbation. Bold numbers are superior results.
Dataset PairFGSMGaussianPGD
(SVHN,CIFAR10)0.9466/0.18160.9400/0.18450.9496/0.1819
(SVHN,CIFAR100)0.8906/0.33600.8842/0.34420.8931/0.3234
(SVHN,MNIST)0.8721/0.42750.8773/0.42020.8719/0.4221
(SVHN,Fashion)0.9584/0.16700.9580/0.15960.9616/0.1172
(CIFAR10,CIFAR100)0.8448/0.45330.8425/0.46500.8483/0.4373
(CIFAR10,MNIST)0.9368/0.23450.9219/0.25960.9571/0.1669
(CIFAR10,Fashion)0.9593/0.14030.9457/0.16730.9657/0.1137
(CIFAR100,MNIST)0.8690/0.33150.8595/0.35250.8706/0.3265
(CIFAR100,Fashion)0.9502/0.18000.9474/0.19250.9516/0.1692
(MNIST,Fashion)0.9589/0.22820.9214/0.30870.9705/0.1521
Table 7. Comparison of the OOD detection performance using large-scale datasets. Bold numbers are superior results.
Table 7. Comparison of the OOD detection performance using large-scale datasets. Bold numbers are superior results.
IDOODLocal EnsemblesKFAC LaplaceNaiveSCODAdvSCOD
SVHNSUN0.94120.95390.95750.95080.9613
iNaturalist0.95460.94990.95050.95490.9635
CIFAR10SUN0.88240.90750.89420.88890.8983
iNaturalist0.84130.85440.84960.85330.8581
CIFAR100SUN0.76130.78220.77790.78140.7925
iNaturalist0.77460.78840.75610.79230.8035
Table 8. Comparison of the OOD detection performance measure by AUROC with different settings of α . Bold numbers are superior results.
Table 8. Comparison of the OOD detection performance measure by AUROC with different settings of α . Bold numbers are superior results.
IDOOD α / 2 α α 2
SVHNCIFAR100.96330.96350.9628
CIFAR1000.95310.95380.9533
CIFAR10SVHN0.94230.94200.9412
CIFAR1000.88280.88300.8815
MNISTFashion0.97130.97140.9701
Table 9. Comparison of the OOD detection performance measure by AUROC with different settings of λ . Bold numbers are superior results.
Table 9. Comparison of the OOD detection performance measure by AUROC with different settings of λ . Bold numbers are superior results.
IDOOD λ = 0.001 λ = 0.01 λ = 0.1 λ = 1
SVHNCIFAR100.96030.96350.96310.9617
CIFAR1000.95160.95380.95240.9512
CIFAR10SVHN0.94130.94200.94110.9402
CIFAR1000.88340.88300.88110.8802
MNISTFashion0.96980.97140.97130.9708
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Qiao, J.; Zhong, C.; Zhu, P.; Tang, K. AdvSCOD: Bayesian-Based Out-Of-Distribution Detection via Curvature Sketching and Adversarial Sample Enrichment. Mathematics 2023, 11, 692. https://doi.org/10.3390/math11030692

AMA Style

Qiao J, Zhong C, Zhu P, Tang K. AdvSCOD: Bayesian-Based Out-Of-Distribution Detection via Curvature Sketching and Adversarial Sample Enrichment. Mathematics. 2023; 11(3):692. https://doi.org/10.3390/math11030692

Chicago/Turabian Style

Qiao, Jiacheng, Chengzhi Zhong, Peican Zhu, and Keke Tang. 2023. "AdvSCOD: Bayesian-Based Out-Of-Distribution Detection via Curvature Sketching and Adversarial Sample Enrichment" Mathematics 11, no. 3: 692. https://doi.org/10.3390/math11030692

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop