Out-of-Distribution Detection via Conditional Kernel Independence Model
Abstract
Recently, various methods have been introduced to address the OOD detectionproblem with training outlier exposure.
These methods usually count on discriminative softmax metric or energy method to screen OOD samples.
In this paper, weprobe an alternative hypothesis on OOD detection by constructing a novel latentvariable model based on independent component analysis (ICA) techniques.
Thisnovel method named Conditional-i builds upon the probabilistic formulation, andapplies the Hilbert-Schmidt Independence Criteria that offers a convenient solutionfor optimizing variable dependencies.
Conditional-i exclusively encodes the usefulclass condition into the probabilistic model, which provides the desired convenience in delivering theoretical support for the OOD detection task.
To facilitatethe implementation of the Conditional-i model, we construct unique memory bankarchitectures that allow for convenient end-to-end training within a tractable budget.
Empirical results demonstrate an evident performance boost on benchmarks against
SOTA methods.
We also provide valuable theoretical justifications that our trainingstrategy is guaranteed to bound the error in the context of OOD detection.
Code isavailable at: https://github.com/anonymoussneurips/conditional-i.
Introduction
The out-of-distribution (OOD) detection ability of models is at the core of achieving machine learningsafety and reliability.
Knowing how the classifiers perform on unseen OOD data remains as achallenging task owing to the train-test distribution divergence [4].
While deep generative modelshave become immensely popular, seminal OOD detection works consider applying these generativemodeling techniques to reconstruct the training data distribution density so that statistical test can beimplemented on the density.
However, it is found that such inference can perform strong predictionartifact owing to various possible reasons [12, 43, 45, 57, 64].
Instead, another line of work considersdeploying discriminative methods on OOD detection [26, 32, 34, 35, 37] where the detection isimplemented by thresholding some class uncertainty measurements obtained from training inlierclassifiers.
However, as the train and test data i.i.d.
assumption is severely violated for the OODdetection task, only limited theoretical guarantees hold when deploying these discriminative models.
There has been a surge of interest in the OOD detection task recently [9, 17, 36, 44, 49, 51, 52, 53, 59].
Unlike previous efforts that rely on canonical discrimination or generative models, we view the
OOD detection problem from a new perspective of the independent component analysis (ICA).
Ourstarting point is the hypothesis that OOD data should exhibit a slight dependency on in-distributiontraining data, which can effectively constrain the OOD data to expose limited mutual informationwith the inliers.
This hypothesis imposes the inliers to extract only little predictive information fromoutliers during training, and we distinguish OOD samples via the related independence measurementsduring the test.
The contemporary work [2] (see supplementary material) attempted to probe
the
OOD problem from a similar view.
However, [2] merely demonstrates the promising practical values of such independence assumption based on empirical success, which lacks theoretical justificationand supporting analysis.
In this work, we propose a brand new motivating generative model, byincorporating additional class conditions into the latent variable model.
This new work also aims toshowcase the theoretical soundness through the transparent lens of ICA techniques, which providesdesired technical convenience.
Our contribution to this paper includes: C1:
We propose a new OOD detection framework called
Conditional-i model (reminiscent of Conditional-i ndependence model).
In comparison to [2],
Conditional-i additionally encodes the class condition into the probabilistic dependence model.
C2:
In order to exclusively facilitate the end-to-end training of the Conditional-i model, we constructan efficient memory bank architecture that constrains the training within a practical computationalbudget.
C3:
Conditional-i can be efficiently implemented both when training OOD data is availableor not.
C4:
We provide theoretical justifications for our new model.
Empirical results demonstratethe evident superiority of our new proposal over the state-of-the-art methods for computer vision and
NLP tasks.
Related Work
Challenges for OOD detection .
In [12, 26, 45, 57], empirical evidence shows that deep generativemodels trained on image datasets can often erroneously assign a high likelihood to OOD inputs.
In the meanwhile, as observed in [22, 31], discriminative models also encounter a similar issue inreturning high confidence on OOD samples or misclassified samples.
Many contemporary worksattempted to understand the principle behind this phenomenon.
The work in [47] figured that theshared background statistics between in-distribution data and OOD data could interfere with the test.
In [45, 57], they discussed the impact of typicality on the the test.
In [64], the work rather challengedthe prevailing typical set hypothesis and the assumption that in-and out-distribution overlap.
In[63], authors argued both accurate density estimation and discriminative classifier are critical, andhenceforth proposed a hybrid model to address the issue.
Research works also aim to alleviate theissue from the view of miscalibration [15, 18, 22, 40].
The work in [17] further demonstrated thatdeep architecture on the OOD detection performance task could have a significant impact.
OOD detection with statistical uncertainty .
Adapting NNs to incorporate uncertainty and probabilistic methods has been of great interest in the community.
The majority of this line of work rely ona Bayesian formalism, called Bayesian Neural Net (BNN).
Many extensions along this path aim toestimate a posterior distribution over the DNN parameters [6, 19, 38] given some prior distributionon the DNN parameters.
However, Bayesian NNs are often harder to implement and are prohibitivelyexpensive in computational complexity.
Some approach then considers reflecting a similar spirit of
BNN [31] with reduced complexity.
In the meanwhile, the statistical tests in differentiating OODdata are also of critical importance.
In [1, 50], hierarchical probabilistic models are used to estimateuncertainty on OOD data.
In [35], authors found that in-distribution data are more sensitive tosoftmax temperature scaling and noise perturbations, under which they proposed a novel statisticaltest.
In [32], the Mahalanobis distance is estimated to reflect the uncertainty of the test data classes.
There are many more explorations along this path [24, 25, 27, 35, 36, 37, 50].
Particularly, a group ofworks assumes some OOD samples are accessible during training [2, 24, 26, 34, 37].
The approachin [26] assigned the “uniform label” on OOD training data to impose the uncertainty on OOD data.
The model in [37] introduced an energy-based score to replace the softmax score, achieving superiorperformance.
The work in [34] investigated sampling policies of the OOD training data to improve
OOD detection performance.
Conditional-i is the first that considers the independence assumption to address the OOD detectionproblem.
Measuring independence and non-linear relationship between features is a classic technique,while independence component analysis (ICA) has powered conventional machine learning techniques[33, 39, 56].
Some emerging work, such as in [65] empirically shows removing non-linear correlationbetween features improves generalization for deep models.
However, these models were built andmotivated for drastically different tasks.
For instance, [65] targets the specific domain generalization(DG) task, whereas Conditional-i is tailored for the OOD detection task, two entirely different taskshaving distinct definitions, modeling assumptions, and evaluation metrics.
In comparison to ourearlier contemporary work HOOD [2], this paper is further motivated by a modified conditionalindependence latent variable model.
The fresh generative model behind Conditional-i provides uniquetechnical convenience in delivering theoretical guarantees by allowing Conditional-i to utilize moreflexible outlier regularizers during training.
Methodology
We introduce variable x ∈ R D to denote in-distribution (inlier) data, and let variable u ∈ R
Drepresent the out-of-distribution (outlier) data.
The in-distribution training data set D trin consists ofannotated pairs of data ( x i , y ini ) , where i indexes training samples.
The label y ini ∈ { 1 , ..., C } =
Y inassigns each x i one out of the C ground truth classes.
A common assumption for OOD detection isthat some out-of-distribution (OOD) samples u can be accessed during training, where u are definedas samples from distinct classes y outi [26, 37].
We cannot access labels of outlier u
i samples.
We define z i = f
( x i ; θ ) ∈ R
d to be the features of inliers x i .
Function f ( · ; θ ) is the deep featureextractor with deep parameters θ to be learned.
The features of OOD sample u i , denoted as q iare also learned through the same feature extractor, i.e., q i =
f ( u i ; θ ) ∈ R d .
Out-of-distributiondetection is essentially a binary classification task that aims to learn efficient f ( · ; θ ) that can separateand discriminate between inliers z and outliers q at test time.
3.1 Motivating principle
In this paper, OOD samples are defined to be from the classes outside the inlier classes Y in , by strictlyfollowing discriminative models [26, 32, 35, 37].
This definition is distinct from the generativemodel based detection methods [12, 45, 57, 64] that samples from a different feature distribution areinstead defined to be OOD data regardless of their classes.
Mainstream discriminative OOD detectionapproaches usually rely on softmax metric [26] or the likes, e.g., energy score [37] to make decisions.
These methods essentially compare the linear correlation between a feature and the classifier weights.
Our aim is to reduce the mutual information between training inliers and training outliers, sincefeatures representing different semantics should confine their predictive ability to each other.
Notethat reducing mutual information between variables implies reduced dependence, while dependencecaptures a more general and complicated statistical relationship than linear correlation.
As a partialstep towards this goal, our new model relies on an explicit conditional independence hypothesis thatis shown to be both theoretical sound and practically superior to the SOTA methods.
Pushing further than our contemporary work formulated as “HOOD” [2] (see supplementary material),our new OOD detection training strategy is built on a novel generative model under particularconditional independence assumption.
Specifically, we define each sample from the c class to bemodeled as a variable x ( c ) generated from a generative process g ( c ) :
R d → R D , x ( c ) i is the i thsample realization of variable x ( c ) :
[Equation]
Here, w ( c ) i are i.i.d.
realizations of variable w ( c ) , and w ( c ) defines the classifier that reflects thecommon components shared between each sample in c class.
Variable β i denotes the latent variabledefining the generative process of the outliers u through function g ( o ) .
Each β i is i.i.d.
sample withfinite first and second moments.
This suggest that we could model z across all classes c ∈ { 1 , ..., C } ,each denoted as z ( c ) , along with q variable to be jointly distributed given θ :
[Equation]
We further define variable ξ as the variable indicating the true class of feature z .
The relevance ofthis construction then becomes apparent as per the following objective on requiring the independencebetween z and q given class c :
[Equation]
where p θ denotes a probability density parameterized by θ .
Penalizing maximum mean dependency(MMD) [20] between the joint distribution on z ( ξ ) , q and product of two conditional distributionsin Eq.
(3) then explicitly regularizes the training so that inlier feature z of every class ξ = c , to beindependent with outlier feature q .
Deep parameter θ is trained so that unseen OOD test data cangeneralize conditional independence given ξ = c , and only lives in the constrained subspace subjectto small loss incurred from Eq.
Contradiction against independence assumptions for any classξ = c would increase dependence metric between q and the generative process defined by ξ = c .
The model above ultimately allows us to incorporate the class condition and the associated generativemodel into an integrated loss function, one that can be directly exploited and practically penalized.
It is of pivotal importance to note that Eq.(3) strongly contrasts with the sampling strategy in
HOOD [2].
It also manifests that
since p θ ( z , q ) = (cid:80) c p θ ( z ( ξ ) , q | ξ = c ) p ( ξ = c ) , then sampling from p θ ( z ( ξ ) , q | ξ = c ) here by conditioning on class ξ further eliminates the sampling artifactintroduced by p ( ξ = c ) of the training dataset.
In this regard, conditioning on each specific c avoidsimplicit marginalization over p ( ξ = c ) as in [2] and instead encourages all in-distribution classes toproduce independent features from outlier classes.
Another compelling reason is that, such additionalconditioning also provides technical convenience in delivering our theoretical guarantees by linkingto the generative model of each specific class, see Theorem 1.
3.2 Conditional independence model for OOD detection
As proposed in [21], the Hilbert-Schmidt Independence Criterion (HSIC) is an effective measurementthat quantifies the variable dependence through the eigenspectrum of covariance operators in reproducing kernel Hilbert spaces (RKHSs).
In [21], it is guaranteed that the HSIC metric is zero if andonly if the random variables are independent.
We therefore anchor our modeling to this principledcriteria, and employ the HSIC metric to encourage the conditional independence between z andq given each observed class c of z .
To reach this goal, during each training iteration, we samplepairs of samples S c,N = { ( z ( c ) 1 , q 1 ) , ( z ( c ) 2 , q 2 ) , ..., ( z ( c ) i , q i ) , ..., ( z ( c ) N , q N ) } from each conditionaldistribution p
θ ( z ( ξ ) , q | ξ = c ) given each class c and current θ .
Here, inlier samples z ( c ) 1 , ..., z ( c ) N outof set S c,N are from the same ground truth class c .
Then, for each class c , Eq.
(3) can be empiricallyestimated via the estimator modified from [21]:
[Equation]
Here the matrices Φ ( c ) z , H , Φ q ∈ R N × N are defined as follows.
The ( i, j ) th entry of matrix Φ ( c ) zis computed as Φ ( c ) z,i,j = k ( z ( c ) i , z ( c ) j ) , and for matrix Φ q , the ( i, j ) th entry is denoted as Φ q,i,j =k ( q i , q j ) .
Here ( z ( c ) i , q i ) and ( z ( c ) j , q j ) are two samples from S c,N .
Matrix H
=
I − 1 N 11 ⊤ , andnotation tr ( · ) computes matrix trace.
In principle, the kernel function k ( · , · ) can take any legitimateform of characteristic kernel in the RKHS, such as Gaussian kernel Φ ( c )
z,i,j = k ( z ( c ) i , z ( c ) j ) =
[Equation]
or linear kernel.
The conditional independence loss sums over all classes is:
[Equation]
In order to facilitate the practical training, we design a specific memory bank architecture in Section3.3, under which the loss R in Eq.
(5) is penalized in closed form.
In the meanwhile, it is crucialto include the conventional softmax classification loss to train for semantically useful features forlabeled in-distribution data, where y i = c is label of z ( c ) i :
[Equation]
The classifier variable w ( c ) to be estimated was defined in generative process Eq.
The overall lossthat backpropagates through the function f ( · ; θ ) is:
[Equation]
, (7) where λ is a pre-defined penalty hyperparameter.
The parameters θ are optimized during the training.
3.3 Implementation of condition independence
In contrast to HOOD [2], Conditional-i model particularly incorporates the additional class conditionc into loss Eq.
Such a new assumption introduces nuanced algorithmic complexity: Computingˆ R ( z , q , c, θ ) over all classes c as in Eq.
(5) is prohibitively expensive and impractical for batchwise training.
To ensure Eq.
(5) stays practically useful, we propose an auxiliary memory bankarchitecture that allows for convenient end-to-end training.
The general idea is to form C numbermemory banks for computing each class specific matrix Φ ( c ) z .
During each training iteration, wedynamically maintain and update memory banks V
= { v 1 , v 2 , ..., v c , ..., v C } .
All memory banksv c are of the size N (i.e., N features in each v c ) and are formed under a queue structure with “firstin first out” policy.
Features z ( c ) i from the current arriving in-distribution mini-batch is enqueuedto each corresponding memory bank v c indexed by class c =
y ( in ) i , and the oldest sample featurez ( c ) j in the queue v c with c = y ( in )
j is removed.
During each training iteration, we randomly sampleˆ C < C classes from V , and use the feature values stored in v c to compute Φ ( c ) z in Eq.
We thencan compute Eq.
(4) with the current arriving batch of OOD feature q of size N , at the current θ .
3.4 A novel statistical test
During test time inference, a natural choice would be to reuse the independence metric of Eq.
(5)for test data.
But we unfortunately cannot sample multiple i.i.d.
samples to construct Φ q duringtest, since we have no access to test data distribution and Φ q would be a constant.
We resolve thisproblem by resorting to a surrogate function that can correctly reflect independence alternatively.
Asdiscussed in [21, 55], HSIC independence metric can be further reduced for standardized features iflinear kernel is used to construct Φ q and Φ ( c ) z , yielding the independence metric:
[Equation]
where Z ∈ R N × d has features z ⊤ i as rows, and Q ∈ R N × d has features q ⊤ i as rows.
We then followthis thread and modify the Eq.
(8) into a novel practical test metric that suits Conditional-i training(different from [2]): during the test, we replace Q in Eq.
(8) by a test feature constructed matrix S i ,where each row in S i ∈ R N × d repeats the identical test feature s ⊤ i ∈ R 1 × d .
We then concatenate allthe training inliers in each c class into each matrix Z ( c )
∈ R d × N , and compute:
[Equation]
Here ∥ · ∥ F is Frobenius norm.
Eq.
(9) searches for the inlier class c that returns the maximumconditional dependence with the test feature s i .
We determine test feature s i to be OOD if t i < α fora predetermined hyperparameter α owing to significant independence with any possible class c ; andclassify it to be inliers if t i ≥ α , showing evident dependence with certain inlier class.
By rangingacross various threshold values α to implement the detection, we obtain the conventional FPR95,
AUROC, and AUPR evaluation metrics by definition [26].
Analysis
The analytic results presented here fully justify Conditional-i’s validity as an advantageous OODdetection algorithm.
Let F denote the function indexed by parameters θ such that for a given input( x (1) i , . . .
, x ( C ) i , u i ) , F ( x (1) i , . . .
, x ( C ) i , u i ; θ ) returns output features ( z (1) i , . .
, z ( C ) i , q i ) , wherez ( c ) i =
f ( x ( c ) i ; θ ) for c
= 1 , . .
, C , indicating the feature extracted from an incidence in class c , andq i =
f ( u i ; θ ) is the feature extracted from an outlier, and f is defined in Section 3.
Our objective
Eq.
(7) over the parameter θ then can be viewed as the Lagrangian of the following constrainedoptimization problem over F :
[Equation]
where symbol ⊥⊥ denotes independence between variables.
4.1 Condition-i versus HOOD
The distinction between HOOD and Conditional-i approach is made apparent by comparing the
HSIC metrics for dependence in the optimization problem.
In HOOD, the metric for dependenceis HSIC HOOD = tr (Φ z H Φ q H ) /
( N − 1) 2 , where Φ z,i,j
= k ( z i , z j ) with z i , z j being samplesfrom the mixture distribution p M ( z ) =
(cid:80) Cc =1 p θ ( z ( ξ ) | ξ = c ) p ( ξ = c ) .
On the other hand, themetric for dependence in Conditional-i is HSIC cond-i = 1 C (cid:80)
Cc
=1 tr (Φ ( c ) z H Φ q H ) /
( N − 1) 2 , whereΦ ( c ) z,i,j = k ( z ( c ) i , z ( c ) j ) are samples from the conditional distribution of inliers given class ξ = c .
Theoutlier features that minimize HSIC HOOD are those independent of inlier features from the mixturedistribution.
The outlier features that minimize HSIC cond-i are those independent of inlier featuresfrom distribution of each of the C classes, and thus also minimize HSIC HOOD , but the opposite isnot necessarily true.
A heuristic is given below in the scenario of d = 1 and linear kernels: Asshown in [55], given the features are standardized, the HSIC metrics can be written as ∥ z ⊤ q ∥ 2 F , andthus the minimizer q of Conditional-i is orthogonal (inner product defined by the correlation) to thespace spanned by features of all classes { z ( c ) :
c = 1 , . . .
, C } .
Minimizers q of HOOD are thoseorthogonal to the linear combination (cid:80) Cc =1 p ( ξ = c )
z ( c ) , which are not necessarily independent
ofeach z ( c ) .
In fact, by choosing proper weights, q can be a weighted combination of { z ( c ) } and stillbe a minimizer of HOOD (see evidence in supplementary file).
4.2 Inlier and outlier independence guarantee
In terms of the optimum of optimization problem Eq.
(10)-(12), we adapt the technique from [39] tosupport our proof (see supplementary file).
But unlike previous efforts as in [39], our approach isanchored in a principled loss function Eq.
(10)-(12) with drastically distinct objective, modeling andbounds tailored for OOD detection task.
Specifically, we propose the following theorem:
Theorem 1.
Suppose F is a solution of the optimization Eq.
In addition, let F ( c ) denotethe function such that F ( c ) ( x (1) , . . .
, x ( c ) , . . .
, x ( C ) , u ) =
z ( c ) , and let F ( c ) l denote the l th elementof the output of F ( c ) for l = 1 , . . .
, d .
Then, the following holds with probability of at least 1 − δ : ∀d 1 , d 2 ∈ { 1 , . . .
, d } , we have
[Equation]
≤
[Equation]
where
ϵ =
ν
+ K 1 R N + 4 C 2 f (cid:112)
log(1 /δ )
/ (2 N ) , and K and K 1 are positive constants.
Particularly, Theorem 1 holds if the below assumptions and definitions are satisfied:
Assumption 1.
i) Admissible generative functions { g ( c ) : c = 1 , . . .
, C } and feature extractors { F ( · ; θ ) } are thirdorder differentiable.
ii)
The Rademacher complexity of the function class { F ( c ) l ( · ; θ ) } for each c and l is bounded by R Ngiven N samples.
iii)
Any third order derivative of function h ( c ) l = F ( c ) l ◦ ( g (1) , . . .
, g ( C ) , g ( o ) ) is in [ − C d , C d ] , whereC d is a finite constant.
In addition, h ( c ) is invertible with respect to w ( c ) .iv)
There exists a positive constant ν such that sup ∥ h ( c ) ( w (1) i , . . .
, w ( C ) i , β i ) − w ( c ) ∥
22 ≤ ν almostsurely for all c .v) sup {| F cl ( x (1) i , . . .
, x ( C ) i , u i ) | , | w ( c ) l |} ≤ C f almost surely for all c and l , where C f is a constant.
Theorem 1 explains why the independence assumption is beneficial for OOD detection.
If we couldachieve perfect independence between z and q through the network f conditional on each ξ = c ,then under mild conditions, we obtain accurate disentanglement between the in-distribution feature zand the true generative variable β that have genuinely generated OOD data, up to a limited error.
Inother words, the variation in OOD generative β does not cause a change in z , as literally described in
Theorem 1.
As the Rademacher complexity increases, the required number of training samples N toachieve accurate independence also increases, in order to effectively bound our disentanglement errorbetween the in-distribution feature and the true generative process of OOD samples.
In this way, Theorem 1 allows us to quantitatively describe how well the inherent generative processof in-distribution data and that of OOD data are disentangled up to an error.
If we were using aconventional softmax classifier to train for the in-distribution data, in the presence of the OOD data,the best disentanglement we can achieve is bounded by Theorem 1.
This justifies the legitimacyand relevance of our proposed method for the OOD detection task, where the detection goal is todifferentiate the samples belonging to different generative classes from the known in-distributionaldata.
This hopefully may better generalize the training to unseen test OODs as long as the generativeprocess of the test OOD is genuinely different.
Theorem 1 only considers the scenario where perfectindependence is achieved through penalizing Eq.
Certainly, we could further introduce an errorterm that bounds how much Eq.
(4) is deviated from zero.
We nevertheless choose to present themost simplified version here for clarity.
We defer the more complicated derivation that Eq.
(4) isnonzero to future work.
Experiments
In this section, we evaluate the performance of the Conditional-i method against the state-of-the-art
OOD detection methods on both computer vision and NLP (natural language processing) applications.
Across all the experiments, the Gaussian kernel is used to compute loss Eq.
We evaluate themodels under two setups: 1.
The training inliers data and training outliers are assumed available,but the labels of training outliers are unknown.
The training outliers are no longer available, andwe manually generate fake outliers by applying strong augmentation [14] and CutMix [61] on thetraining inliers.
All models are tested on a mixture of test inliers and outliers with the goal of correctlyidentifying outliers.
We compare all methods in terms of FPR95, AUROC, and AUPR metrics [26].
[Table]
[Table]
5.1 Datasets and baselines
282 Datasets.
In-distribution training data: We respectively use the CIFAR-100 and ImageNet1Kas the in-distribution training data for image OOD detection tasks.
We employ the 20 Newsgroupsdata as the in-distribution training data for the NLP OOD detection task.
OOD training data: Byfollowing the protocol in [26], we use the 80 Million Tiny Images [54] as the OOD training datawhen the In-distribution data is CIFAR-100 [30].
We let the ImageNet21K [48] be the OOD trainingdata when ImageNet1K [48] is the in-distribution training data.
We define WikiText-2 [42] to betraining OOD, when 20 Newsgroups is in-distribution data.
In-distribution test data: We use thevalidation data from the corresponding in-distribution dataset as the in-distribution test data as definedin [26].
OOD test data: We employ the benchmarks: DTD [13], SVHN [46], Places69 [66], LSUN[60], and CIFAR-10 [30] as the OOD detection test data for computer vision tasks; We use SNLI [8],
IMDB [41], Multi30K [16], WMT16 [7], Yelp [3], and EWT [5] as OOD test data for NLP tasks.
The specific training in- and out- distribution pairing strategy is (illustrated as inlier training data:
OOD test data) CIFAR-100: DTD, SVHN, Places365, LSUN, and CIFAR-10; ImageNet1K: DTD,
SVHN, Places365, and LSUN; 20 Newsgroups: SNLI, IMDB, Multi30K, WMT16, Yelp, and EWT.
Baselines: The alternative SOTA baselines are K-Base [25], ODIN [35], Mahalanobis distance [32], OE [26], Energy [37], ReAct [52], GradeNorm [28] and HOOD [2].
Here, K-Base [25] correspondsto the model trained through simple softmax loss using in-distribution data, while the OOD detectiontest is implemented by thresholding the maximum softmax prediction score.
5.2 Training architecture and optimization
We use the WideResNet-28-10 [62] and ResNet18 [23] as the training backbone for vision tasks, withthe final deep feature dimension d = 640 for WideResNet-28-10 and d = 512 for ResNet18.
Weemploy the SGD optimizer with lr = 0 .
1 , Nesterov Momentum 0.9, for both Table 1 and 2.
We usetwo-layer GRU [10] for producing Table 3 with Adam [29] optimizer.
For Table 1 and 2, we adoptbatchsize = 256 and 512 respectively for in-distribution data.
For Table 3, we use batchsize = 64for in-distribution data.
Every benchmark method in Table 1 and 2 is trained for 100 epochs w.r.t.the size of the in-distribution training data.
For NLP experiments, we train 2-layer GRUs [11] for5 epochs for Table 3 (See supplementary material for details).
We train each algorithm on 1 {+P
+} GPU.
In contrast to the sampling as in [2] and [26] which sequentially sample random blocks ofdata from 80 Million Tiny Images, we firstly randomly shuffle the training dataset before sampling.
The shuffling is expected to eliminate the sampling bias owing to the inherent correlation betweenthe sample ordering and the categories.
We found that such shuffling has improved all the baselines.
We believe we have tuned all the baseline models to our best.
By following the protocol in [26], we
[Table]
[Table] [Table] [Table] report the average performance by using the consistent hyperparameters, without tuning for eachspecific test dataset.
The detailed results of each specific test can be found in the supplementary file.
5.3 Benchmark results
Image OOD detection tasks.
We first present the OOD detection results in Table 1, where the
CIFAR-100 dataset serves as in-distributional data, with 80 Million Tiny Images being the OODtraining dataset.
DTD, SVHN, Places365, LSUN, and CIFAR-10 are tested as OOD data.
We tunedall the compared methods based on the validation set defined in [26].
It manifests from Table 1that Conditional-i generally outperforms all the existing SOTA OOD methods in terms of FPR95, AUROC, and AUPR metrics.
Particularly, Conditional-i surpasses our earlier HOOD method by anevident margin, justifying the unique advantage of the Conditional-i model as discussed in 4.1.
Wefound that the Conditional-i approach is especially efficient in differentiating near OOD samples,such as distinguishing CIFAR-10 from CIFAR-100, while it also provides decent performanceagainst large domain gaps, e.g., CIFAR-100 vs. DTD.
In Table 2, where ImageNet1K is inlierand ImageNet-21K is outlier, the performance of Conditional-i is even further improved whenfiner classes of OOD training data are used for training.
This verifies that, by capitalizing on theconditional-independence assumption, Conditional-i exploits unique constraints when searching forthe OOD feature parameterization, and henceforth shows advantageous generalization ability underthe finer classes’ OOD discrimination.
This also best support the relevance of our Theorem 1, that
Conditional-i can distinguish inliers and outliers depending on the true generative process of testsamples given their class conditions.
Training without access to known true OOD training data.
Proceeding further, we compare allmodels when we lose access to the oracle training OOD data.
In this scenario, we use generated fake OOD training data by applying strong augmentation [14] and CutMix [61] (for CV tasks) or EDA [58]techniques (for NLP tasks) on each in-distributional data (see supplementary material).
Each "XX"baseline trained with fake OOD training data is referred to as “XX-generative” (e.g., Conditional-igenerative).
As displayed in Table 1 and 2, Conditional-i-generative performs relatively worse thanthe vanilla Conditional-i model, owing to the absence of true OOD data.
However, Conditional-igenerative not only beats all SOTA models without OOD training data exposure, including K-Base, ODIN, Mahalanobis distance, Energy, and ReAct(+Energy), but also exhibits evident gain over otherexposure methods, i.e., OE-generative and HOOD-generative.
Here, ReAct(+Energy) corresponds tothe ReAct [52] method based on Energy [37].
NLP OOD detection tasks.
We observe from Table 3 that Conditional-i offers the strong OODdetection performance on texts across all the evaluation metrics.
The advantage of Conditional-i isparticularly evident in the AUPR metric, that the Conditional-i model is more than 1% better than the HOOD model, and is 2% better than the OE method.
Note although GradeNorm [28] shows superiorperformance in AUPR metric when training OOD is unavailable, it nevertheless performs poorly interms of the other metrics, showing the unique benefit of Conditional-i on NLP applications.
5.4 Ablation study
Ablation on memory bank architecture .
The proposed memory bank architecture is necessary andis exclusively designed to facilitate the Conditional-i training.
However, to explain the advantageof conditional independence modeling hypothesis against HOOD, it is crucial to ablate the effectof the additional memory bank that is absent in HOOD training.
We refer to this new baseline as
HOOD-bank, which is constructed with the identical memory bank architecture of Conditional-i.
F P R 95 ( % ) (a) FPR 0.
A U R O C ( % ) (b) AUROC 0.
A U P R ( % ) (c) AUPR
The critical difference here is that each 1 out of C memory bank for HOOD-bank is instead filledwith random in-distribution data regardless of their class category.
Each arriving in-distribution datarandomly chooses 1 out of C memory banks with a probability 1 /C and joins the correspondingqueue.
We compute the batch-wise loss function as in Eq.
(5) by ranging across ˆ C number of memorybanks of inliers data, where ˆ C < C classes are sampled from C total memory banks as defined in
Section 3.3.
In this way, samples in Φ ( c ) z are no longer sampled i.i.d.
by conditioning on the classvariable c for HOOD-bank.
Rather, samples in each bank follow the marginal distribution of p ( z | θ )by margining out the classes.
Tables 1, 2, 3 clearly demonstrate that, the memory bank architecturealone, i.e., HOOD-bank method, can hardly boost HOOD.
The advantage of Conditional-i is mainlyattributed to the new conditional latent model.
This result directly justifies Section 4.1.
Ablation on number of classes ˆ C .
We investigate the impact of sampled class number ˆ C includedfor computing Eq.
(5), by following the procedure in Section 3.3.
The training setup is the same asfor producing Table 2.
We still keep using the total number of classes present in the in-distributionaldata to train the inlier classifier through Eq.
In the meanwhile, we reduce the number of classesincluded in Eq.
(5) to ˆ C < C and examine the regularizing impact of the additional condition on the
OOD detection performance.
As shown in Table 4, as more in-distributional data join the loss Eq.
(5),the network gradually learns to shrink the subspace in which the OOD training sample can live in, sothat the OOD features well to respect the independence condition posed by each in-distributionalclass.
While we increase the value of ˆ C , the performance keeps improving across all the metrics,until all classes are included.
Ablation on in-distributional batchsize N .
We vary the in-distributional data batch size duringtraining, with the training setup identical to Table 1.
Since computing Conditional-i loss involves theestimator construction as in Eq.(4), the number of samples used to compute the kernel matrix Φ czand Φ q would affect the estimator bias in terms of the actual independence.
As displayed in Table 5,the OOD detection performance significantly drops when the in-distribution batch size is below 32,owing to the increased estimator bias introduced through Eq.
Ablation on weight λ .
The weight λ balances the classification loss and the strength of the conditionalindependence loss.
When λ = 0 , Conditional-i degenerates to the K-Base method.
When λ = 0 .
03 ,the OOD detection performance reaches a sweet point owing to the inclusion of the kernel basedindependence calculation.
However, beyond λ = 0 . 03 , the performance starts to drop again, partiallybecause this overemphasized independence starts to hurt the in-distribution semantic feature extractionthat relies on the accuracy of inlier classification.
Learning independence from the noisy semanticshaving high classification loss would then lose the benefit.
Conclusion and Broader Impact
We propose a novel OOD detection approach referred to as Conditional-i. Inspired by the ICAtechniques, Conditional-i is shown to be effectively penalizing the deep feature dependency betweeninliers and outliers.
Conditional-i models conditional independence by incorporating the conditioninformation c into the probabilistic model.
Such independence can be explicitly penalized throughthe use of the HSIC metric.
We constructed an efficient memory bank architecture critical forthe practical implementation of the method in an end-to-end training manner.
Empirical evidencejustifies the superior performance of the proposed method on both computer vision and naturallanguage processing benchmarks.
We believe OOD detection is an important task regarding AI safety.
The accuracy of OOD detection directly impacts the reliability of many AI applications, includinghealthcare, anomaly detection, autonomous driving, and others.
The negative impact is that thedevelopment of the Conditional-i method is subject to the limitations of current SOTA scores we canachieve, which may limit the actual safety of the AI applications.
Whereas Conditional-i achievesthe SOTA performance, another limitation though, is that Conditional-i needs to be trained on (fake)
OOD training data, that might potentially encounter generalization issues, by virtue of [4].
Checklist
For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s
contributions and scope?
[Yes]
(b) Did you describe the limitations of your work?
[Yes] See Section 6.
(c) Did you discuss any potential negative societal impacts of your work?
[Yes] See
Section 6.
(d) Have you read the ethics review guidelines and ensured that your paper conforms to
them?
[Yes]
If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results?
[Yes] See Section 4.
(b) Did you include complete proofs of all theoretical results?
[Yes] See Supplementary
material.
If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experi-
mental results (either in the supplemental material or as a URL)?
[Yes] See Section
and the code URL in abstract.
(b) Did you specify all the training details (e
g., data splits, hyperparameters,
how they
were chosen)?
[Yes] See Section 5 and supplementary file.
(c) Did you report error bars (e g., with respect to the random seed after running experi- ments multiple times)?
[Yes] See Section 5.
(d) Did you include the total amount of compute and the type of resources used (e g., type of GPUs, internal cluster, or cloud provider)?
[Yes] See Section 5.
If you are using existing assets (e
g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators?
[Yes]
(b) Did you mention the license of the assets?
[Yes] See the code URL in abstract.
(c) Did you include any new assets either in the supplemental material or as a URL?
[Yes]
See the code URL in abstract.
(d) Did you discuss whether and how consent was obtained from people whose data you’re
using/curating?
[Yes] See the code URL in abstract.
(e) Did you discuss whether the data you are using/curating contains personally identifiable
information or offensive content?
[N/A]
If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if
applicable?
[N/A]
[Table]
[Table]
[Table]
[Table]