A Simple and Effective  Baseline for Out-of-Distribution Detection using Abstention

1 INTRODUCTION AND RELATED WORK . Most of supervised machine learning has been developed with the assumption that the distribution of classes seen at train and test time are the same . However , the real-world is unpredictable and open-ended , and making machine learning systems robust to the presence of unknown categories and out-of-distribution samples has become increasingly essential for their safe deployment . While refraining from predicting when uncertain should be intuitively obvious to humans , the peculiarities of DNNs makes them overconfident to unknown inputs Nguyen et al . ( 2015 ) and makes this a challenging problem to solve in deep learning . A very active sub-field of deep learning , known as out-of-distribution ( OoD ) detection , has emerged in recent years that attempts to impart to deep neural networks the quality of `` knowing when it doesn ’ t know '' . The most straight-forward approach in this regard is based on using the DNNs output as a proxy for predictive confidence . For example , a simple baseline for detecting OoD samples using thresholded softmax scores was presented in Hendrycks & Gimpel ( 2016 ) . where the authors provided empirical evidence that for DNN classifiers , in-distribution predictions do tend to have higher winning scores than OoD samples , thus empirically justifying the use of softmax thresholding as a useful baseline . However this approach is vulnerable to the pathologies discussed in Nguyen et al . ( 2015 ) . Subsequently , increasingly sophisticated methods have been developed to attack the OoD problem . Liang et al . ( 2018 ) introduced a detection technique that involves perturbing the inputs in the direction of increasing the confidence of the network ’ s predictions on a given input , based on the observation that the magnitude of gradients on in-distribution data tend to be larger than for OoD data . The method proposed in Lee et al . ( 2018 ) also involves input perturbation , but confidence in this case was measured by the Mahalanobis distance score using the computed mean and covariance of the pre-softmax scores . A drawback of such methods , however , is that it introduces a number of hyperparameters that need to be tuned on the OoD dataset , which is infeasible in many real-world scenarios as one does not often know in advance the properties of unknown classes . A modified version of the perturbation approach was recently proposed in in Hsu et al . ( 2020 ) that circumvents some of these issues , though one still needs to ascertain an ideal perturbation magnitude , which might not generalize from one OoD set to the other . Given that one might expect a classifier to be more uncertain when faced with OoD data , many methods developed for estimating uncertainty for DNN predictions have also been used for OoD detection . A useful baseline in this regard is the temperature scaling method of Guo et al . ( 2017 ) that was was proposed for calibrating DNN predictions on in-distribution data and has been observed to also serve as a useful OoD detector in some scenarios . Further , label smoothing techniques like mixup Zhang et al . ( 2017 ) have also been shown to be able to improve OoD detection performance in DNNs Thulasidasan et al . ( 2019 ) . An ensemble-of-deep models approach , that is also augmented with adversarial examples during training , described in Lakshminarayanan et al . ( 2017 ) was also shown to improve predictive uncertainty and succesfully applied to OoD detection . In the Bayesian realm , methods such as Maddox et al . ( 2019 ) and Osawa et al . ( 2019 ) have also been used for OoD detection , though at increased computational cost . However , it has been argued that for OoD detection , Bayesian priors on the data are not completely justified since one does not have access to the prior of the open-set Boult et al . ( 2019 ) . Nevertheless , simple approaches like dropout – which have been shown to be equivalent to deep gaussian processes Gal & Ghahramani ( 2016 ) – have been used as baselines for OoD detection . Training the model to recognize unknown classes by using data from categories that do not overlap with classes of interest has been shown to be quite effective for out-of-distribution detection and a slew of methods that use additional data for discriminating between ID and OD data have been proposed . DeVries & Taylor ( 2018 ) describes a method ithat uses a separate confidence branch and misclassified training data samples that serve as a proxy for OoD samples . In the outlier exposure technique described in Hendrycks et al . ( 2018 ) , the predictions on natural outlier images used in training are regularized against the uniform distribution to encourage high-entropy posteriors on outlier samples . An approach that uses an extra-class for outlier samples is described in Neal et al . ( 2018 ) , where instead of natural outliers , counterfactual images that lie just outside the class boundaries of known classes are generated using a GAN and assigned the extra class label . A similar approach using generative samples for the extra class , but using a conditional Variational Auto-Encoders Kingma & Welling ( 2013 ) for generation , is described in Vernekar et al . ( 2019 ) . A method to force a DNN to produce high-entropy ( i.e. , low confidence ) predictions and suppress the magnitude of feature activations for OoD samples was discussed in Dhamija et al . ( 2018 ) , where , arguing that methods that use an extra background class for OoD samples force all such samples to lie in one region of the feature space , the work also forces separation by suppressing the activation magnitudes of samples from unknown classes The above works have shown that the use of known OoD samples ( or known unknowns ) often generalizes well to unknown unknown samples . Ineed , even though the space of unknown classes is potentially infinite , and one can never know in advance the myriad of inputs that can occur during test time , empirically this approach has been shown to work . The abstention method that we describe in the next section borrows ideas from many of the above methods : as in Hendrycks et al . ( 2018 ) , we uses additional samples of real images and text from non-overlapping categories to train the model to abstain , but instead of entropy regularization over OoD samples , out method uses an extra abstention class . While it has been sometimes argued in the literature that that using an additional abstention ( or rejection ) class is not an effective approach for OoD detection Dhamija et al . ( 2018 ) ; Lee et al . ( 2017 ) , comprehensive experiments we conduct in this work demonstrate that this is not the case . Indeed , we find that such an approach is not only simple but also highly effective for OoD detection , often outperforming existing methods that are more complicated and involve tuning of multiple hyperparameters . The main contributions of this work are as follows : • To the best of our knowledge , this is the first work to comprehensively demonstrate the efficacy of using an extra abstention ( or rejection class ) in combination with outlier training data for effective OoD detection . • In addition to being effective , our method is also simple : we introduce no additional hyperparameters in the loss function , and train with regular cross entropy . From a practical standpoint , this is especially useful for deep learning practitioners who might not wish to make modifications to the loss function while training deep models . In addition , since outlier data is simply an additional training class , no architectural modifications to existing networks are needed . • Due to the simplicity and effectiveness of this method , we argue that this approach be considered a strong baseline for comparing new methods in the field of OoD detection . 2 OUT-OF-DISTRIBUTION DETECTION WITH AN ABSTAINING CLASSIFIER . ( DAC ) Our approach uses a DNN trained with an extra abstention class for detecting out-of-distribution and novel samples ; from here on , we will refer to this as the deep abstaining classifier ( DAC ) . We augment our training set of in-distribution samples ( Din ) with an auxiliary dataset of known out-of-distribution samples ( D̃out ) , that are known to be mostly disjoint from the main training set ( we will use Dout to denote unknown out-of-distribution samples that we use for testing ) . We assign the training label of K + 1 to all the outlier samples in D̃out ( where K is the number of known classes ) and train with cross-entropy ; the minimization problem then becomes : min θ E ( x , y ) ∼Din [ − logPθ ( y = ŷ|x ) ] + Ex , y∼D̃out [ − logPθ ( y = K + 1|x ) ] ( 1 ) where θ are the weights of the neural network . This is somewhat similar to the approaches described in Hendrycks et al . ( 2018 ) as well as in Lee et al . ( 2017 ) , with the main difference being that in those methods , an extra class is not used ; instead predictions on outliers are regularized against the uniform distribution . Further the loss on the outlier samples is weighted by a hyperparameter λ which has to be tuned ; in contrast , our approach does not introduce any additional hyperparameters . In our experiments , we find that the presence of an abstention class that is used to capture the mass in D̃out significantly increases the ability to detect Dout during testing . For example , in Figure 1 , we show the distribution of the winning logits ( pre-softmax activations ) in a regular DNN ( left ) . For the same experimental setup , the abstention logit of the DAC produces near-perfect separation of the in and outof-distribution logits indicating that using an abstention class for mapping outliers can be a very effective approach to OoD detection . Theoretically , it might be argued that the abstention class might only capture data that is aligned with the weight vector of that class , and thus this approach might fail to detect the myriad of OoD inputs that might span the entire input region . Comprehensive experiments over a wide variety of benchmarks described in the subsequent section , however , empirically demonstrate that while the detection is not perfect , it performs very well , and indeed , much better than more complicated approaches . Once the model is trained , we use a simple thresholding mechanism for detection . Concretely , the detector , g ( x ) : X → 0 , 1 assigns label 1 ( OoD ) if the softmax score of the abstention class , i.e. , pK+1 ( x ) is above some threshold δ , and label 0 , otherwise : g ( x ) = { 1 if pK+1 ( x ) ≥ δ 0 otherwise ( 2 ) Like in other methods , the threshold δ has to be determined based on acceptable risk that might be specific to the application . However , using performance metrics like area under the ROC curve ( AUROC ) , we can determine threshold-independent performance of various methods , and we use this as one of our evaluation metrics in all our experiments . 3 EXPERIMENTS . The experiments we describe here can be divided into two sets : in the first set , we compare against methods that are explicitly designed for OoD detection , while in the second category , we compare against methods that are known to improve predictive uncertainty in deep learning . In both cases , we report results over a variety of architectures to demonstrate the efficacy of our method .

Summary: I read this paper with great interest. The authors propose an easy-to-understand, easy-to-implement baseline method for detecting when inputs to a ML model is out of distribution. The method involves augmenting the training dataset with  an out of distribution dataset and adding an additional class in the classification layer for out of distribution. The paper describes several experiments—some in computer vision, some in NLP—and then compares them to other OOD techniques. The results are comparable to other techniques, although the proposed technique is definitely simpler.