Year: 2021

Abstract:
Moving beyond testing on in-distribution data, works on Out-of-Distribution (OOD) detection have recently increased in popularity. A recent attempt to categorize OOD data introduces the concept of near and far OOD detection. Specifically, prior works define characteristics of OOD data in terms of detection difficulty. We propose to characterize the spectrum of OOD data using two types of distribution shifts: covariate shift and concept shift, where covariate shift corresponds to change in style, e.g., noise, and concept shift indicates change in semantics. This characterization reveals that sensitivity to each type of shift is important to the detection and confidence calibration of OOD data. Consequently, we investigate score functions that capture sensitivity to each type of dataset shift and methods that improve them. To this end, we theoretically derive two score functions for OOD detection, the covariate shift score and concept shift score, based on the decomposition of KL-divergence for both scores, and propose a geometricallyinspired method (Geometric ODIN) to improve OOD detection under both shifts with only in-distribution data. Additionally, the proposed method naturally leads to an expressive post-hoc calibration function which yields state-of-the-art calibration performance on both in-distribution and out-of-distribution data. We are the first to propose a method that works well across both OOD detection and calibration, and under different types of shifts.

heading: 1 INTRODUCTION
text: Out-of-distribution (OOD) detection is a fundamental research area important for downstream tasks with open-world assumptions such as continual learning (Smith et al., 2021), open-set learning (Yu et al., 2020) and safety-critical applications such as self-driving (Bojarski et al., 2016). However, common OOD detection benchmarks1 are not well categorized. This prevents us from more systematically studying of OOD detection. A recent attempt (Winkens et al., 2020; Fort et al., 2021) to provide a more granular characterization of OOD data introduces the concept of near OOD (Winkens et al., 2020; Fort et al., 2021). Near OOD detection is posed as a more challenging problem than far OOD detection because near OOD datasets usually share similar semantics, and style, e.g., all natural images of similar environment, as the training dataset. Existing works characterize OOD in terms of difficulty of OOD detection such as Confusion Log Probability (CLP) (Winkens et al., 2020). However, this characterization only conveys difficulty of OOD detection across a single dimension and does not expose intrinsic characteristics of OOD data.
In this paper we provide a more systematic categorization of OOD data, which motivates a more robust OOD detection method and helps us reflect on some existing approaches. Specifically, there are at least two dimensions along which we can characterize the spectrum of OOD data. Intuitively, out-of-distribution data refers to data that are sampled from distributions different from the training distribution. This is well known in machine learning as distribution shift (Moreno-Torres et al., 2012). There are two dominant shift types: covariate shift2 and concept shift. The former usually
1Texturess (Cimpoi et al., 2014), SVHN (Netzer et al., 2011), Place365 (Zhou et al., 2017), LSUNCrop/Resize (Yu et al., 2015), and iSUN (Xu et al., 2015)
2Covariate shift is often associated with model calibration (Ovadia et al., 2019; Chan et al., 2020)
refers to change in style, e.g., clean to noised and natural images to cartoon, and the latter refers to change in semantics, e.g., dog to cat. Even though existing works Hsu et al. (2020) have acknowledged the different types of OOD datasets and the difficulty of detecting them, their methods do not distinguish them and do not explicitly disentangle them. To study these two distribution shifts, we propose to create a benchmark with multiple magnitude of distribution shift in each dimension. Specifically, we use corrupted CIFAR10C/CIFAR100C (Hendrycks & Dietterich, 2019), originally developed for testing robustness, with varying degrees of severity to represent increasing covariate shift; we also introduce a new benchmark, CIFAR100 Splits, which divides the CIFAR100 dataset into 10 splits with increasing conceptual shift from CIFAR10 classes, measured by semantic similarity in a word embedding space (Pennington et al., 2014). We show that the increasing conceptual difference measured by semantic similarity in language translates to a spectrum of OOD datasets under gradual concept shift measured by the difficulty of OOD detection in the image space.
To address these two distribution shifts, we need to approach it from two aspects: representation and modeling, analogous to the role of entropy and Bayesian inference in uncertainty quantification (Depeweg et al., 2018) where entropy is a score function that represents uncertainty and Bayesian inference is a method that models uncertainty (Hüllermeier & Waegeman, 2021). To represent these two shifts, we can derive score functions which output scalars indicating the severity of distribution shift. Specifically we derive two score functions by expanding and decomposing the KL divergence between a predictive distribution from a classifier and a discrete uniform distribution. Arising from the decomposition is a covariate shift score which is a function of feature norms and a concept shift score which is a function of feature angles. To model these two shifts, and motivated by the covariate score (a function of norms) and the concept score (a function of angles), we propose to directly improve the sensitivity of norms and angles to distribution shift through a geometric perspective (Tian et al., 2021). Specifically, we adopt the Geometric Sensitivity Decomposition proposed in Tian et al. (2021), originally developed for model calibration, which decomposes norms and angles into a variance component and a scalar offset, and improve it by parametrizng the scalar offsets as standalone networks. Our approach improves detection of OOD data under both covariate and concept shifts.
While OOD detection and calibration3 has been studied separately in the literature, they share the same underlying motivation: confidence/uncertainty should be low/high when distribution shift occurs. Our method to improve OOD detection naturally yields a powerful calibration function in the family of intra class-preserving functions (Rahimi et al., 2020). This class of functions provides enough expressive power to calibrate complex decision boundaries in neural networks and proves to be effective in calibration on in-distribution data. Therefore, we apply a post-calibration (Guo et al., 2017) method on a validation set as described in those works. Additionally, thanks to the improved sensitivity to distribution shift, our model also is on par with state-of-the-art calibration performance on distribution shifted data as well. To summarize our contributions:
• We propose to characterize the spectrum of OOD data in terms of covariate and concept shift and unify the notion of near OOD in different literature (Sec. 3.1). Additionally, we construct a new benchmark (e.g., CIFAR100 Splits) to represent gradual distribution shift in each direction (Sec. 4.1.2 and 4.1.3).
• To represent distribution shifts, we analytically derive two OOD score functions based on KL-divergence to capture both shifts more effectively (Sec. 3.2).
• To model distribution shifts, we propose Geometric ODIN to improve the sensitivity of neural networks during training (Sec. 3.3) and calibration during inference (Sec. 3.4). This method achieves state-of-the-art performance on both detection (Sec. 4.1) and calibration (Sec. 4.2) of OOD data.

heading: 2 RELATED WORK
text: Out-of-Distribution (OOD) detection methods can be largely divided into two camps depending on whether they require OOD data during training. Hendrycks et al. (2018); Thulasidasan et al. (2020); Roy et al. (2021) leverages anomalous data in training. Our method belongs to the class of methods that do not assume the availability of OOD data during training. Hendrycks & Gimpel (2016) uses the maximum softmax probability (MSP) to detect incorrect predictions and OOD data. Lee et al.
3OOD detection focuses on concept-shifted data while calibration focuses on covariate-shifted data.
(2018) proposes to use Mahalanobis distance by fitting a Gaussian mixture model (GMM) in the feature space. Mukhoti et al. (2021) uses log density of the GMM model instead. Liu et al. (2020b) uses an energy score as the uncertainty metric. ODIN (Liang et al., 2017) uses a combination of input processing and post-training tuning to improve OOD detection performance. Generalized ODIN Hsu et al. (2020) (also Techapanurak et al. (2019)) includes an additional network in the last layer to improve OOD detection during training. There are other interesting OOD detection approaches without OOD data such as using contrastive learning with various transformations (Winkens et al., 2020; Tack et al., 2020), training a deep ensemble of multiple models (Lakshminarayanan et al., 2016) and leveraging large pretrained models (Fort et al., 2021). They require extended training time, hyperparameter tuning and careful selections of transformations, whereas our method does not introduce any hyperparameters and has negligible influence on standard cross-entropy training time.
Model Calibration methods can also be largely divided in two categories: 1) training time calibration using augmentations (Thulasidasan et al., 2019; Jang et al., 2021), using modified losses (Kumar et al., 2018); 2) post-hoc calibration (Guo et al., 2017; Kull et al., 2019; Kumar et al., 2019; Rahimi et al., 2020). Recently, Rahimi et al. (2020) formally generalizes a family of expressive functions for calibration, the intra order-preserving functions. This class of functions has more representation power to calibrate more complex decision boundaries in neural networks. Our proposed method belongs to this class of functions. However, all these works focus on calibration of in-distribution data. To obtain better calibration on OOD data, on which the confidence of a model needs to decrease accordingly, sensitivity and deterministic uncertainty modeling is explored by SNGP (Van Amersfoort et al., 2020) and DUQ (Liu et al., 2020a). Our proposed model not only belongs to the family of intra order-preserving functions, which ensures good in-distribution calibration, but also improves sensitivity to distribution shift, which improves out-of-distribution calibration simultaneously. Please refer to Appendix 6.8 for a more detailed discussion on related works.

heading: 3 METHOD

heading: 3.1 MOTIVATION: COVARIATE AND CONCEPT SHIFT
text: We follow Moreno-Torres et al. (2012) for the formal definition of distribution shift, covariate shift and concept shift. LetX ∈ RD denote the covariate which is the input and Y ∈ R denote the output label. Distribution shift happens when the training joint distribution is not equal to the testing joint distribution Ptr(X,Y ) 6= Ptst(X,Y ). Covariate shift appears when Ptr(Y |X) = Ptst(Y |X) and Ptr(X) 6= Ptst(X). Concept shift appears when Ptr(Y |X) 6= Ptst(Y |X) and Ptr(X) = Ptst(X). However, in the image domain, it is rare that such concept shift occurs without changes in P (X). We therefore modify the equality in concept shfit to Ptr(X) ≈ Ptst(X) where superficial, low-level statistics may be retained.
Specifically, covariate shift happens when the testing data is non-semantically different from the training data and concept shift happens when the testing data is semantically different from the training data. We illustrate a spectrum of OOD dataset in Fig. 1. In this example, CIFAR10 is the training dataset. CIFAR100 represents concept shift because CIFAR100 has a non-overlapping label space, i.e., Ptr(Y |X) 6= Ptst(Y |X), but similar style with CIFAR10. The corrupted CIFAR10C dataset (Hendrycks & Dietterich, 2019) represents covariate shift because it has the same labels but
different style, i.e., Ptr(X) 6= Ptst(X), compared to CIFAR10. SVHN represents both covariate and concept shift due to its non-overlapping label space and very different style.
As shown in Fig. 2, the first goal of this paper is to derive score functions to represent the shift in either P (X) or P (Y |X). We denote the score function that reflects change from Ptr(X) to Ptst(X) as the covariate shift score function: g(x) : RD → R and the score function that reflects change from Ptr(Y |X) to Ptst(Y |X) as the concept shift score function: h(y, x) : Y × RD → R. The second goal is to improve the sensitivity of these scores to their corresponding distribution shift. Specifically, we propose a geometrically inspired out-of-distribution detection method with only indistribution data (Geometric ODIN). The third goal is to show that, unlike prior works which treat OOD detection (Mukhoti et al., 2021) and calibration (Van Amersfoort et al., 2020; Liu et al., 2020a) separately, our proposed Geomeric ODIN naturally leads to an expressive calibration function in the family of intra order-preserving functions (Rahimi et al., 2020), which ensures good calibration.

heading: 3.2 COVARIATE AND CONCEPT SCORE FUNCTIONS
text: In this section, we theoretically derive two score functions, g(x) and h(y, x), based on the KLdivergence between a uniform distribution U and a predicted distribution P ∈ RM , where M is the number of classes. By starting from KL-divergence, we hinge the subsequent derivation of score functions on a physical meaningful uncertainty measure, i.e., how far the predicted distribution is from a uniform distribution. This relationship ensures a natural interpretation of score functions because predictions on distribution shifted data should have larger uncertainty, i.e. smaller distance from uniform. We are specifically interested in softmax-linear models for classification. They typically consist of a feature extractor and a linear layer followed by a softmax activation. Let f ∈ RD denote a feature vector from the feature extractor4. The output of the linear layer, i.e., logits, l ∈ RM =< f ,W > is defined as the inner product between the feature vector and a weight matrix in the linear layer. Let li = ‖f‖2‖wi‖2 cosφi denote the ith logit, Pi = exp li∑M
j=1 exp lj denote
the predicted probability of the ith class. The KL-divergence KL(U||P) can be written as following:
KL(U||P) = − M∑ i=1 1 M lnMPi = ln M∑ j=1
exp lj︸ ︷︷ ︸ Log−Sum−Exp
− 1 M M∑ i=1 li − lnM (1)
Now we can use the inequality property of Log-Sum-Exp (LSE)5 functions in Eq. 2 to bound Eq. 1.
max j lj ≤ ln M∑ j=1 exp lj ≤ max j lj + lnM (2)
Therefore the KL-divergence (Eq. 1) can be bounded as follows:
U − lnM ≤ KL(U||P) ≤ U (3) 4Bold letter indicates vectors 5Note that the negative LSE function is also defined as free energy in Liu et al. (2020b).
where U = maxj lj− 1M ∑M i=1 li. U can be further decomposed into two multiplicative components by plugging in the definition of logits li:
U = max j lj −
1
M M∑ i=1 li = g(x)︷︸︸︷ ‖f‖2 ( max j ‖wj‖2 cosφj − 1 M M∑ i=1 ‖wi‖2 cosφi ) ︸ ︷︷ ︸
h(y,x)
(4)
We define the covariate shift score function as g(x) , ‖f‖2 because the norm of a feature vector is the sum of squared activation values and only depends on the input. Intuitively, activation of a neural network on covariate-shifted data should be weaker than in-distribution data. Therefore, g(x) assigns a higher value to in-distribution data than to OOD data. We define the concept shift score function as h(y, x) , maxj ‖wj‖2 cosφj − 1M ∑M i=1 ‖wi‖2 cosφi because it is the difference between the cosine distance of the predicted class and the average cosine distance of all classes and depends on both the input and final class membership, assigned by the max operator. Intuitively, class assignment should be less obvious under concept shift and the difference should be small. Consequently, h(y, x) assigns a higher value to in-distribution data than to OOD data.In retrospect, our definition of covariate shift and concept shift scores supports existing findings that the feature norms correspond to intra-class variance and angles reflect inter-class variation (Liu et al., 2018). Intuitively, covariate shift represents non-semantic change within a specific class, i.e., intra-class variance; concept shift represents semantic changes, i.e, inter-class variation. Here we formalize the intuition and observations in Liu et al. (2018) as score functions derived analytically from a KL-divergence viewpoint. We provide an extended discussion of these scores in Appendix 7.
More importantly, the combined score function U (Eq. 4) carries a physical meaning: it bounds the KL-divergence between a uniform distribution and the predictive distribution. Intuitively, a small U indicates large uncertainty because U upper bounds KL(U||P), and a large U indicates small uncertainty because it also appears in the lower bound. We can derive U also by Taylor-expanding the softmax equation as in Liang et al. (2017), which claims that U is responsible for good OOD detection. Our findings confirm this and push it further by decomposing it into different components. A similar scoring function, S(x) = ‖f‖2 maxj ‖wj‖2 cosφj , is used in Tack et al. (2020), but is only empirically motivated based on observations with limited analytical insights such as its relationship to uncertainty and the functionality of each of components. In contrast, our derivation clearly shows the relationship between these score functions and the KL-divergence, which is as an uncertainty measure, and disentangles their roles. We will compare the g(x), h(y, x) and U as score functions in subsequent experiments and analyze their respective sensitivity to different shifts (Sec. 4.1).
3.3 GEOMETRIC OUT-OF-DISTRIBUTION DETECTION WITH IN-DISTRIBUTION DATA
As derived in Eq. 4, the covariate score is a function of feature norms and the concept score is a function of feature angles. Consequently, improving the sensitivity of feature norms and feature angles to data shifts seems to be the natural next step to improve OOD detection. Therefore, we adopt Geometric Sensitivity Decomposition (GSD) (Tian et al., 2021) (reviewed in appendix 6.3) to improve sensitivity to covariate and concept shifts. Specifically, GSD improves sensitivity by extracting sensitive components from norms ‖f∗‖26 and angles |φ∗i | through a decomposition of them into: a scalar offset and a variance component as shown in Eq. 5. Scalar offsets Cf and Cφ minimize the loss on the training set and the variance components f and φi account sensitively for variances in samples.
‖f∗‖2 = ‖f‖2 + Cf , |φ∗i | = |φi| − |Cφ| (5)
With the decomposed components, the original logit l∗i = ‖f∗‖2‖wi‖2 cosφ∗i , can be written as:
l∗i = ‖f∗‖2‖wi‖2 cosφ∗i ≈ li =  1cos Cφ︸ ︷︷ ︸ α ‖f‖2 + 1 cos Cφ︸ ︷︷ ︸ α β︷︸︸︷ Cf  ‖wi‖2 cosφi (6) 6The superscript ∗ denotes the original component before decomposition.
where li denote the new ith logit. In Eq. 6, the new7 feature f is a direct output of a feature extractor, and is modified by α and β as also illustrated Fig. 2. Note that the calculation of score functions in Sec. 3.2 only uses the feature and is independent of α and β.
Because cos Cφ and Cf are scalar offsets, we can parametrize them separately from the main network. Unlike GSD which parametrizes them as instance-independent scalars, inspired by Hsu et al. (2020); Techapanurak et al. (2019), we make α(f) and β(f) instance-dependent scalars and use a single linear layer to learn them. To enforce numerical constraints, i.e., 0 < α < 1 and β > 0, α(f) uses a sigmoid activation and β(f) uses a softplus activation. Finally, the relaxed output is:
P (Y = i|x) = exp li∑M j=1 exp lj = exp
(( 1
α(f)‖f‖2 + β(f) α(f) ) ‖wi‖2 cosφi ) ∑M j=1 exp (( 1 α(f)‖f‖2 + β(f) α(f) ) ‖wj‖2 cosφj
) (7) Now the new predicted norm ‖f‖2 and angle φi are more sensitive to input changes because they encode variances in samples as shown in Eq. 5. Therefore, including β (related to norms) improves sensitivity to covariate shift and including α (related to angles) improves sensitivity to concept shift. Note that, under this construction, Generalized ODIN (Hsu et al., 2020) is a special case of our proposed method. Generalized ODIN only includes the α(f) which only improves angle sensitivity but not norm sensitivity. Unlike Hsu et al. (2020)’s probabilistic perspective8, our model builds on a geometric perspective and captures both covariate and concept shifts by improving norm and angle sensitivity. The new model can be trained identically as the vanilla network without additional hyperparameter tuning and extended training time. Combined with score functions derived in Sec. 3.2, Geometric ODIN achieves state-of-the-art OOD detection performance (Sec. 4.1)

heading: 3.4 CALIBRATION OF GEOMETRIC ODIN
text: Like most softmax-linear classification models, Geometric ODIN also suffers from miscalibration right after training. Specifically, predictions tend to be overconfident (Guo et al., 2017). In the case of Geometric ODIN, the cause of overconfidence is obvious by construction. The offset scalars β(f) and α(f) are designed to minimize the training loss. Practically, they are optimized to push the predicted probability of the ground truth class to be close to 1 during training, and this intended behavior unsolicitedly continues to inference time when accuracy is not as high as during training. Nevertheless, our construction of α(f) and β(f) belongs to a family of intra order-preserving functions, which has potentially strong representation to calibrate complex functions in deep networks according to Theorem 1 in Rahimi et al. (2020). To prove that, it’s suffice to show that that α(l) and β(l) 9 forms a strictly positive function, m(l) as shown in Eq. 8
l̄i =
( 1
α(l) ‖f‖2 +
β(l)
α(l)
) ‖wi‖2 cosφi = ( 1
α(l) +
β(l)
α(l)‖f‖2 ) ︸ ︷︷ ︸
m(l)
li︷ ︸︸ ︷ ‖f‖2‖wi‖2 cosφi (8)
Because 0 < α(l) < 1 and β(l) > 0, the function m(l) is strictly positive and thus satisfies Theorem 1 in Rahimi et al. (2020) (See appendix 6.4 for more details). We follow a simple procedure proposed in Guo et al. (2017); Rahimi et al. (2020) to calibrate Geometric ODIN by minimizing the negative log likelihood (NLL) on a evaluation dataset for a few epochs. During calibration the gradients to other parts of the model are stopped and only these two linear layers, α(l) and β(l), are optimized (Fig. 2). Naturally with the improved sensitivity and calibrated functions, the calibration of Geometric ODIN is on par with state-of-the-art models on both in-distribution and OOD data. Note that, as mentioned in Sec. 3.3, because the calculation of score functions for OOD detection only depends on the feature f and is independent of α and β, calibration does not affect the OOD detection performance and does not change prediction results due to the order-preserving property.
7Even though both f∗ and f are outputs directly from the feature extractor, we use original and new to indicate whether GSD is applied.
8α(f) is interpreted as P (din|x), the probability of x being in-distribution. 9Following Rahimi et al. (2020), which uses logits l as input instead of the feature f . Our derivation in
previous sections is still valid because l solely depends on f given a model.

heading: 4 EXPERIMENTS
text: In this section, we present results for Out-of-Distribution detection in Sec. 4.1 and calibration in Sec. 4.2. We are the first to present a method that works well on both OOD detection and calibration, disentangling shift types. Implementation: Following prior works (Liu et al., 2020a; Van Amersfoort et al., 2020; Mukhoti et al., 2021), we use Wide-ResNet-28-10 (Mukhoti et al., 2021) for all experiments. We train the model using SGD with an initial learning rate of 0.1 for 200 epochs. The learning rate is annealed with a cosine scheduler (Loshchilov & Hutter, 2016) (more details in appendix 6.5). Metrics: For OOD detection in Sec. 4.1, we use the common AUROC and TNR@TPR95 as benchmark metrics. For calibration in Sec. 4.2, we use the Expected Calibration Error (ECE) (Guo et al., 2017) with 15 bins and Negative Log Likelihood (NLL) which is a strictly proper scoring rule (Gneiting & Raftery, 2007). Datasets: CIFAR10 (Krizhevsky et al., a) and CIFAR100 (Krizhevsky et al., b) are considered near OOD datasets (Winkens et al., 2020; Fort et al., 2021) to each other. SVHN (Netzer et al., 2011) is considered a far OOD dataset to both CIFAR10 and CIFAR100 due to its shift in both concept and style. The CIFAR10C/CIFAR100C (Hendrycks & Dietterich, 2019) dataset is a variant of CIFAR10/CIFAR100 corrupted by 15 types of noises with 5 degrees of severity. We also introduce CIRAF100 Splits benchmark which consists of 10 datasets with increasing concept shift from CIFAR10 classes (Sec. 4.1.3).

heading: 4.1 OUT-OF-DISTRIBUTION DETECTION RESULTS

heading: 4.1.1 NEAR AND FAR OOD DETECTION
text: The α-β model is the best. In Tab. 1, we present OOD detection results against state-of-the-art methods on existing near and far OOD categorization. For near OOD detection under strong concept shift, CIFAR10 (ID) vs. CIFAR100 (OOD), both our α-only and α-β variants achieve the the best performance. This demonstrates that α(x) improves the sensitivity of angles and hence the sensitivity to concept-shifted data. For near OOD detection under strong covariate shift, CIFAR10 (ID) vs. CIFAR10C (OOD), the α-β variant achieves the the best performance. This suggests that β(x) improves the sensitivity of norms and hence the sensitivity to covariate-shifted data. In CIFAR100 (ID) vs. CIFAR10 (OOD) experiments, the performance of the α-only and α-β variants are within variance and is close to some other compared methods, we can not make clear observations from those experiments10. For far OOD detection, CIFAR10/CIFAR100 (ID) vs. SVHN (OOD), the α-β model achieves state-of-the-art performance. This reconfirms that β(x) improves sensitivity to covariate-shifted data, because SVHN has both covariate and concept shifts compared to the CIFAR datasets, and the α-β model outperforms the α-only variant, which only improves on concept shift, by a noticeable margin. In terms of score functions, the best performing one for the α-β model is U , which is a product of g(x) and h(y, x) (Sec. 3.2), while that of the α-only model is h(y, x). This shows that depending on which component is more sensitive, different scoring functions are
10Other confounding factors could contribute to the close performance. Prior works either omit comparisons under these settings (Mukhoti et al., 2021) or report only marginal improvement (Winkens et al., 2020)
preferred. When the sensitivity of both norms and angles are improved, as in the α-β variant, the combined score function U performs well under different distribution shifts.

heading: 4.1.2 OOD DETECTION UNDER COVARIATE SHIFT WITH IMAGE CORRUPTION
text: The g(x) score captures covariate shift. We compare the α-β, α-only (β = 0), β-only (α = 1) variants and the vanilla model on CIFAR10C (Hendrycks & Dietterich, 2019) corrupted by motion blur in Fig. 3 with increasing degrees of noise (see appendix 6.7 for additional experiments). From 3a, we observe that 1) as covariate shift severity increases, OOD detection becomes easier because AUROC increases with increasing severity. 2) the vanilla model is more sensitive to the concept shift component because h(y, x) > g(x) in the vanilla model plot even though covariate shift is the dominant distribution shift in this example. 3) when sensitivity to both covariate and concept shift is improved , the α-β model becomes more sensitive to the covariate shift component. This suggests that the dominant shift in this example is indeed covariate shift. From Fig. 3b, we observe that the α-β model outperforms the β-only model using the combined score function U . This suggests that improving sensitivity to both shifts and using U yield the best OOD detection performance. In retrospect, the performance of OOD detection has always relied on two components: the model and the score function. Some works propose more responsive score functions, e.g., energy in Liu et al. (2020b), and some works propose more sensitive models, e.g., DDU in Mukhoti et al. (2021) to improve the performance of existing score functions.

heading: 4.1.3 OOD DETECTION UNDER CONCEPT SHIFT WITH CIFAR100 SPECIAL SPLITS
text: Finding a dataset to benchmark gradual concept shift is not straightforward because concept shift is traditionally thought as binary: overlapping or non-overlapping. However, not all non-overlapping labels are the same. For example, pickup truck (CIFAR100) is semantically much closer to truck (CIFAR10) than sunflowers (CIFAR100) is. To create this gradual concept/semantic shift, we propose to divide the CIFAR100 dataset into 10 sub-datasets with increasing conceptual difference from CIFAR10 classes. Specially, we use 300 dimensional Glove word embeddings11 (Pennington et al., 2014) trained on the entire wikipedia2014 and Gigaword5 (Napoles et al., 2012) to measure semantic closeness (inner product) between CIFAR100 and CIFAR10 classes. The result is 10 subdatasets split from CIFAR100. Please refer to appendix 6.6 for the full splits.
The h(y, x) score captures concept shift. Following the previous section, we benchmark the α-β, α-only, β-only variants and the vanilla model on the newly created CIFAR100 Splits. From Fig. 4a, we observe that 1) as concept shift severity increases, OOD detection becomes easier because AU-
11https://nlp.stanford.edu/projects/glove/
ROC increases with increasing severity. 2) both concept shift and covariate shift are present because AUROC using either h(y, x) or g(x) increases. 3) the vanilla model is dominantly more sensitive to the concept shift component because concept shift is the dominant distribution shift in CIFAR100 Splits by construction and vanilla ResNet is more sensitive to concept shift (the same behavior is also observed on covariate-shift-heavy data in Sec. 4.1.2). 4) when sensitivity to both shifts is improved, the α-β model is still more sensitive to concept shift (h(y, x) > g(x)). This reconfirms that the dominant shift type is indeed concept shift. From Fig. 4b, interestingly, we observe that all three variants perform similarly and all outperform the vanilla model. Combined with previous observations that the dataset has strong concept shift and the vanilla model is already very sensitive to concept shift, improving sensitivity to the covariate shift component yields equally good performance as improving sensitivity to both shifts.

heading: 4.2 OUT-OF-DISTRIBUTION CALIBRATION RESULTS
text: As proved in Sec. 3.4, our model naturally leads to a calibration function in the family of intra order-preserving functions (Rahimi et al., 2020), which ensures good in-distribution calibration performance. Moreover, thanks to the improved sensitivity, the model can potentially achieve state-of-the-art out-of-distribution calibration as well. We benchmark our models on both clean CIFAR10/CIFAR100 as well as corrupted CIFAR10C/CIFAR100C (Hendrycks & Dietterich, 2019). Following prior works (Rahimi et al., 2020), we use 5-fold cross validation for in-distribution calibration experiments. As shown in Tab. 2 and Tab. 3, our model is comparable to state-of-the-art models on both in-distribution and out-of-distribution calibration. In the literature, OOD detection and calibration have been studied separately, but our method and experimentation tackles both tasks.

heading: 5 CONCLUSION
text: In this work, we propose to characterize the spectrum of out-of-distribution (OOD) data using covariate shift and concept shift. Unlike difficulty of OOD detection, distribution shift exposes intrinsic characteristics of OOD data. Consequently, to achieve good OOD detection performance, a model needs to consider both distribution shifts. At representation level, we derive two score functions that represent and capture each shift separately. At modeling level, inspired by these score functions, we propose a geometrically-inspired method, Geometric ODIN, to improve a model’s sensitivity to both shift. Furthermore, Geometric ODIN is the first method that considers both OOD detection and calibration, targeting both concept and covariate shifts, and yields state-of-the-art performance in both tasks. Finally, we hope that the distribution shift perspective can lead to a new direction to study OOD data and unify the the fields of detection and calibration of OOD data.

heading: 6 APPENDIX

heading: 6.1 INTRODUCTION TO OUT-OF-DISTRIBUTION DETECTION
text: Out-of-Distribution detection is the task of separating in-distribution data from out-of-distribution (OOD) data. For example, a classifier, trained on a training distribution Ptr(X,Y ), is tested on a different test joint distribution Ptst(X,Y ). When the test joint distribution Ptst(X,Y ) 6= Ptr(X,Y ), data sampled from Ptst(X,Y ) are considered OOD data. Ptst(X,Y ) can be different in two ways, i.e., covariate shift and concept shift (Sec. 3.2). Data sampled from the same distribution as training, Ptr(X,Y ), such as a conventional validation/test split, are in-distribution (ID) data. To detect OOD data, a score function is used such as maximum softmax probability (Hendrycks & Gimpel, 2016) and energy (Liu et al., 2020b). The score function assigns higher value to OOD data than ID data. Consequently, OOD data can be detected by setting a suitable threshold. The commonly used benchmark, Area Under the Receiver Operating Characteristic curve (AUROC), plots true positive rate of ID data against false positive rate of OOD data by sweeping through a range of thresholds, and is a threshold-independent metric for measuring OOD detection performance.

heading: 6.2 INTRODUCTION TO CONFIDENCE CALIBRATION
text: Colloquially, confidence calibration refers to aligning the maximum predicted probability (confidence) from a multi-class classifier to the empirical accuracy of the predicted class to be the ground truth. For example, if a classifier classifies 100 images to dog with a confidence of 0.8 for each prediction, than 80 out of 100 those images should contain a dog. Formally, we adopt the definition from Kull et al. (2019) to define confidence calibration. Let P̂ : X → ∆x be a probabilistic multiclass classifier for M classes. For any input x ∈ X , P̂(x) = (P̂1(x), ..., P̂M (x)) is a probability vector.
Definition 1 A probabilistic classifier P̂ : X → ∆x is confidence-calibrated, if for any p ∈ [0, 1]

heading: P (Y = arg max P̂(x)|max P̂(x) = p) = p
text: One notion of confidence calibration is the expected difference between the confidence and accuracy.
EP̂ [∣∣∣P (Y = arg max P̂(x)|max P̂(x) = p)− p∣∣∣] Expected Calibration Error (ECE) (Naeini et al., 2015) (Guo et al., 2017) is a metric that approximates this expectation. ECE partitions predictions into several M equally-sized bins according to the predicted confidence, and then calculates average accuracy and confidence for each bin. Let ŷ and p̂ be the predicted class and confidence of an input x with corresponding label y. Bn denotes the n-th bin. The accuracy and confidence are calculated for each bin as follows:
acc(Bn) = 1 |Bn| ∑ i∈Bn 1(ŷi = yi) (9)
conf(Bn) = 1 |Bn| ∑ i∈Bn p̂i (10)
Than ECE is defined as a weighted sum of the difference between confidence and accuracy in each bin. Therefore, lower ECE indicates better calibration.
ECE = N∑ n=1 |Bn| N |acc(Bn)− conf(Bn)|

heading: 6.3 GEOMETRIC SENSITIVITY DECOMPOSITION REVIEW
text: Geometric sensitivity decomposition (GSD) is proposed in Tian et al. (2021) to improve the sensitivity of neural networks to input changes. Specifically, GSD views the output of the last linear layer, i.e., logits, in a softmax-linear model as inner products, between the feature and weights in
the linear layer, , l ∈ RM =< f ,W >. The inner products can be written as products of norms and cosine similarity, e.g., the ith logit is l∗i = ‖f∗‖2‖wi‖2 cosφ∗i . GSD proposes to decompose norms, ‖f∗‖2, and angles, φ∗i , into two components: an instance-dependent residual component and an instance-independent scalar as shown in Eq. 11. The instance-independent scalar acts as freely optimizable parameters during training to minimize training loss.{
‖f∗‖2 = ‖f‖2 + Cf |φ∗i | = |φi| − |Cφ|
(11)
Decomposed components in Eq. 11 can be plugged into equation for logits.
‖f∗‖2 cosφ∗i = ‖f∗‖2 cos |φ∗i | = (‖f‖2 + Cf ) cos (|φi| − |Cφ|) (12)
= (‖f‖2 + Cf ) 1
cos |Cφ| cos |φi| 1− sin |Cφ|2 1− cos |Cφ| sin |φi|sin |Cφ| cos |φi|︸ ︷︷ ︸
E.q. 13
 
Eq. 12 can be simplified by assuming that the angle |φ∗i | is small. This equivalent assumes that training data are closely clustered to linear classifiers specified by the linear weight W.
cos |Cφ| sin |φi| sin |Cφ| cos |φi| = sin (|φi|+ |Cφ|) + sin |φi| sin (|φi|+ |Cφ|)− sin |φy| ≈ 1 (13)
Therefore, logits can be written as the following.
‖f∗‖2‖wi‖2 cosφ∗i ≈  1cos Cφ︸ ︷︷ ︸ α ‖f‖2 + 1 cos Cφ︸ ︷︷ ︸ α β︷︸︸︷ Cf  ‖wi‖2 cosφi (14) Because cos Cφ and Cf are instance-independent, we can parametrize them separately from the main network as α and β respectively.

heading: 6.4 INTRA ORDER PRESERVING FUNCTIONS REVIEW
text: Rahimi et al. (2020) formalizes a family of powerful calibration function: intra order preserving functions. Many familiar functions are in this family such as the softmax function and temperature scaling (Guo et al., 2017). Formally, a function f : Rn → Rn is intra order-preserving if for any x ∈ Rn, both x and f(x) share share the same ranking. The following theorem from Rahimi et al. (2020) provides sufficient and necessary conditions for constructing an intra order preserving function.
Theorem 1 A continuous function f : Rn → Rn is intra order-preserving, if and only if f(x) = S(x)−1Uw(x) with U being an upper-triangular matrix of ones and w : Rn → Rn being a continuous function such that
• wi(x) = 0 if yi = yi−1 and i < n,
• wi(x) > 0 if yi > yi1 and i < n,
• wn(x) is arbitrary
where y = S(x)x is the sorted version (descending, i.e., y1 ≥ y2) of x and S(x) : Rn → Rn is a sorting matrix.
The task of constructing an intra order preserving function comes down to designing the function w(x). A specific form of w(x) is proposed in Rahimi et al. (2020): wi(x) = σ(yi − yi−1)mi(x).
As long as σ is a positive function, i.e., σ(x) = 0 when x = 0 and σ(x) > 0 otherwise, and m(x) > 0 is a strictly positive function, the contructed function will satisfy Theorem 1.
Our construction of α and β satisfies the necessary conditions. For calibration, the function f acts on the logits l so we use l instead of x in subsequent proof. Let li = ‖f‖2‖wi‖2 cosφi denote the sorted12 ith logit and l̄i = ( 1 α(l)‖f‖2 + β(l) α(l) ) ‖wi‖2 cosφi detnote the actual output ith
logit (sorted) with α and β. The goal is to show that l̄ and l share the same ranking by satisfying Theorem 1. We start by extracting the m(x) function in Eq. 15.
l̄i =
( 1
α(l) ‖f‖2 +
β(l)
α(l)
) ‖wi‖2 cosφi = ( 1
α(l) +
β(l)
α(l)‖f‖2 ) ︸ ︷︷ ︸
m(l)
li︷ ︸︸ ︷ ‖f‖2‖wi‖2 cosφi (15)
Therefore, we can construct the w(x) function by taking the difference between two adjacent logits for i < n.  wi(l) = l̄i − l̄i−1 = ( 1 α(l) + β(l) α(l)‖f‖2 ) ︸ ︷︷ ︸ m(l)>0 σ≥0︷ ︸︸ ︷ (li − li−1), for i < n
wi(l) = li for i = n
(16)
where li ≥ li−1. Because 0 < α(l) < 1 and β(l) > 0, the functionm(l) is strictly positive and thus satisfies Theorem 1 in Rahimi et al. (2020). Specifically, m(l) corresponds to the strictly positive function m(x) and li − li−1 corresponds to the positive function σ(yi − yi−1), due to the sorting in descending order.

heading: 6.5 IMPLEMENTATION DETAILS
text: Out-of-Distribution Detection Following prior works (Liu et al., 2020a; Van Amersfoort et al., 2020; Mukhoti et al., 2021), we use Wide-ResNet-28-10 (Mukhoti et al., 2021) for all OOD detection experiments. We train the model using SGD and cross entropy loss with an initial learning rate of 0.1 for 200 epochs. The SGD optimizer is configed with 5.0e− 4 weight decay and 0.9 momentum. Batch size is 128. The learning rate is annealed with a cosine scheduler (Loshchilov & Hutter, 2016). We adopt the official code13 for the implementation of DDU (Mukhoti et al., 2021). DDU (Mukhoti et al., 2021) and Mahanobis (Lee et al., 2018) distance use density estimation by fitting a Gaussian mixture model (GMM) to the learned feature space. We use the official implementation of DDU to fit a GMM to the feature space (feature from the CNN). For Manhanobis distance, we fit a GMM to the low dimensional logit space instead for computational stability.
Calibration The backbone training follows the same procedure as the previous section. During the calibration/tuning stage, we train all models for 20 epochs with cosine learning rate decay using SGD and cross entropy loss. In this stage, we freeze the backbone models and only tune the calibration parameters/functions following (Guo et al., 2017). In our case, only α and β are tuned. For calibration on out-of-distribution data, the models are tuned on the entire validation set. For calibration on in-distribution data, we use 5-fold cross validation using the validation set following prior work (Rahimi et al., 2020). For matrix scaling Guo et al. (2017) and Dirichlet scaling (Kull et al., 2019), we use the Off-Diagonal and Intercept Regularisation (ODIR) (Kull et al., 2019) with a default scaling of 1× 10−7. Note that we use the same initial learning rate, 0.1, for all methods except for Dirichlet scaling. Dirichlet scaling requires smaller learning rate and we tuned the learning rate on different datasets. For CIFAR10, we use 0.01 and for CIFAR100 we use 0.005.

heading: 6.6 CIFAR100 CONCEPT SHIFT SPLITS
text: While it is natural to associate covariate shift with increasing degrees of image corruption, finding a dataset to benchmark gradual concept shift is not straightforward because concept shift is traditionally thought as binary: overlapping or non-overlapping. However, not all non-overlapping labels
12The original order can be restored by applying S(l)−1 to l. 13https://github.com/omegafragger/DDU
are the same. For example, pickup truck (CIFAR100) is much closer to truck (CIFAR10) than sunflowers (CIFAR100) is semantically. To create this gradual concept/semantic shift, we propose to divide the CIFAR100 dataset into 10 sub-datasets with increasing conceptual difference from CIFAR10 classes. Specially, we use Glove word embeddings (Pennington et al., 2014) wtih 6 billion tokens trained on the entire wikipedia2014 and Gigaword5 (Napoles et al., 2012) to measure semantic closeness (inner product) between CIFAR100 and CIFAR10 classes. The result is 10 subdatasets split from CIFAR100 as shown in Tab. 4. Our experiments demonstrate that the conceptual difference measured by semantic similarity in language translates to a spectrum of near OOD datasets measured by the difficulty of OOD detection in the image space.

heading: 6.7 ADDITIONAL RESULTS
text: We provide additional results and tabulated results of figures in the main paper. Specifically, Tab. 5 and Tab. 8 are tabulated versions of Fig .3 and Fig. 4 in the main paper respectively. In addition to motion blur, we also provide out-of-distribution detection results on shot noise in Tab. 7 and zoom blur in Tab. 6.

heading: 6.8 EXTENDED RELATED WORK
text: Out-of-Distribution (OOD) detection methods can be largely divided into two camps depending on whether they require OOD data during training. Hendrycks et al. (2018) leverages anomalous
data in training which enables classifiers to generalize and detect unseen OOD data. Thulasidasan et al. (2020) extends existing classifier to include an OOD class. Roy et al. (2021) assigns multiple classes for outliers instead of a single class. Our method belongs to the class of methods that do not assume the availability of OOD data during training. Hendrycks & Gimpel (2016) discovers that correctly classified examples have larger maximum softmax probability (MSP) and propose to use it to detect incorrect predictions and OOD data. Lee et al. (2018) proposes to use Mahalanobis distance by fitting a Gaussian mixture model (GMM) in the feature space. Mukhoti et al. (2021) uses log density of the GMM model instead. Liu et al. (2020b) uses an energy score as the uncertainty metric to distinguish between in-distribution and OOD data. ODIN (Liang et al., 2017) uses a combination of input processing and post-training tuning to improve OOD detection performance. Generalized ODIN Hsu et al. (2020) (also Techapanurak et al. (2019)) includes an additional network in the last layer to improve OOD detection during training. There are many other interesting OOD detection approaches that have achieved state-of-the-art performance without OOD data such as using contrastive learning with various transformations (Winkens et al., 2020; Tack et al., 2020), training a deep ensemble of multiple models (Lakshminarayanan et al., 2016) and leveraging large pretrained models (Fort et al., 2021). They require extended training time, hyperparameter tuning and careful selections of transformations, whereas our method does not introduce any hyperparameters and has negligible influence on standard cross-entropy training time. For example, Winkens et al. (2020) trains a constrastive model for 1200 epochs on CIFAR100 whereas our model requires only 200 epochs (same as standard classifier training) on the same dataset.
Model Calibration methods can also be largely divided in two categories: 1) training time calibration using augmentations (Thulasidasan et al., 2019; Jang et al., 2021), using modified losses (Kumar et al., 2018); 2) post-hoc calibration (Guo et al., 2017; Kull et al., 2019; Kumar et al., 2019; Rahimi et al., 2020). Guo et al. (2017) proposes to calibrate the confidence of a trained classifier using temperature scaling, a single scalar that softens overconfident softmax predictions. Kull et al. (2019) extends single-class confidence calibration to multiclass calibration using the Dirichlet distribution. Kumar et al. (2019) proposes a scaling-binning calibrator that is more sample efficient. Recently, Rahimi et al. (2020) formally generalizes a family of expressive functions for calibration, the intra order-preserving functions. This class of functions has more representation power to calibrate more complex decision boundaries in neural networks. Our proposed method belongs to this class of functions. However, all these works focus on calibration of in-distribution data. To obtain better calibration on OOD data, on which the confidence of a model needs to decrease accordingly, sensitivity and deterministic uncertainty modeling is explored by SNGP (Van Amersfoort et al., 2020) and DUQ (Liu et al., 2020a). SNGP uses a bounded spectral normalization regularization (Miyato et al., 2018) during training and DUQ adopts a two-sided gradient penalty (Gulrajani et al., 2017) to improve model sensitivity to distribution shift. Our proposed model not only belongs to the family of intra order-preserving functions, which ensures good in-distribution calibration, but also improves sensitivity to distribution shift, which improves out-of-distribution calibration simultaneously.

heading: 7 DISCUSSION ON COVARIATE AND CONCEPT SCORE DECOMPOSITION
text: In Sec. 3.2 in the main paper, two score functions are proposed to capture changes due to covariate and concept shift. As shown in Eq. 17, g(x) denotes the covariate shift score function and h(y, x) denotes the concept shift score function.
U = max j lj −
1
M M∑ i=1 li = g(x)︷︸︸︷ ‖f‖2 ( max j ‖wj‖2 cosφj − 1 M M∑ i=1 ‖wi‖2 cosφi ) ︸ ︷︷ ︸
h(y,x)
(17)
Conceptually, these two scores disentangle covariate shift and concept shift. However, in practice, both shifts almost always happen at the same time in the image domain, i.e., covariate shifted data, e.g., noised data, often result in concept shift, i.e., increasing ambiguity in class assignment. Therefore, both scores can increase and decrease simultaneously as observed in Sec. 4.1.2 and Sec. 4.1.3. The importance of separating them conceptually is to provide a clean perspective to study robust out-of-distribution detection methods that will work well on different situations under either a single distribution shift or a mixed of shifts. It very likely that better score functions can be derived to better disentangle the effects of distribution shifts. In turn, methods that improve sensitivity of those new score functions can be motivated.

heading: 8 ADDITIONAL FIGURES
text: While it seems impossible that concept shift could happen without change in P (x), this is possible if we define the support,P (x), as the distribution of pixels, ie., the lowest level characteristics, completely stripped of any semantic information. A simple example would be reshuffling the pixels of a CIFAR10 image where the semantics, P (y|x) , is completely changed, while P (x) remains the same. Using CIFAR100 to represent concept shift is based on this reasoning. We provide a visualization of pixel distributions of CIFAR10, CIFAR100 and SVHN in Fig. 5c. CIFAR10 and CIFAR100 share very similar pixel distributions while the pixel distributions of SVHN are very different from those of CIFAR10. The similarity in pixel distributions between CIFAR10 and CIFAR100 could be attributed to the data generation/collection process.
To further support the statement that norms are sensitive to covariate shift and justify the choice of defining the covariate shift score g(x) = ||x||2, we show a visualization of CIFAR10 classes in the feature space of a model trained on CIFAR10 in Fig. 5a and 5b. Similar to Liu et al. (2018), we change the last feature dimension of a ResNet to 3. In this way, we can directly visualize the learned feature space without resorting to dimension reduction techniques such as T-SNE (Wattenberg et al., 2016). In addition to the clean validation data from CIFAR10, we also visualize CIFAR10 data corrupted by Gaussian noise. The noised data represents severe covariate shift. We can observe that the noised data are clustered around the origin indicating very small norms.

Review summaries:
The paper starts from the KL divergence between a uniform distribution and the predicted distribution, based on which two score functions are derived for covariate shift and concept shift, respectively. The covariate shift score measures the feature norm while the concept shift score is essentially the difference between the cosine distance of the predicted class and the average cosine distance of all classes.  Furthermore, the paper integrates a variant of the geometric sensitivity decomposition method introduced in a recent work into the proposed score functions, aiming to make them more sensitive to distribution shift and to help calibrate the model as well.  A new dataset called CIFAR 100 Splits is also built, which contains 10 sub-datasets with an increasing level of concept shift compared to CIFAR 10.  The results show that the proposed approach achieves decent performance in OOD detection (in both the scenarios of covariate shift and concept shift) as well as calibration.

This paper studies the problem of Out-Of-Distribution detection, which a focus on analyzing the covariate and concept shift. Leveraging these analysis, it further investigate score functions that capture sensitivity to those shifts and then theoretically derive new score functions, to improve OOD detection. This proposed method leads to a calibration function that obtain the state-of-the-art calibration performance on both in-distribution and out-of-distribution data. Experiments are conducted on small image recognition benchmarks, such as CIFAR100 and SVHN. 

The submission proposes to evaluate covariate shift and "concept shift" through two scoring functions, one based on feature norms (for covariate shift) and the other based on angles (for concepts). To help the network decouple norms and angles, (a modified version of) a very recent method is used to decompose the feature norm and the cosine-distances and also calibrate the network. Experimental results appear to demonstrate good performance on both near and far OOD examples, as well as on calibration metrics. 

This paper proposes a method for detecting two types of distributional shifts: covariate shifts in the input space $\mathcal{X}$ (due to input corruption) and semantic shifts (due to test data falling outside the support set of ID classes, $ y_\text{test} \notin \mathcal{Y}$). The idea is based on the decomposition of KL-divergence between softmax prediction and a uniform vector. Furthermore, the authors propose Geometric ODIN to improve OOD detection and calibration, outperforming strong baseline on CIFAR10, CIFAR 100, and SVHN datasets.