Improving Dirichlet Prior Network for Out-of-Distribution Example Detection

1 INTRODUCTION . Deep neural networks ( DNNs ) have achieved impeccable success to address various real world tasks ( Simonyan & Zisserman , 2014a ; Hinton et al. , 2012 ; Litjens et al. , 2017 ) . However , despite impressive , and ever-improving performance in various supervised learning tasks , DNNs tend to make over-confident predictions for every input . Predictive uncertainties of DNNs can be confronted from three different factors such as model uncertainty , data uncertainty and distributional uncertainty ( Malinin & Gales , 2018 ) . Model or epistemic uncertainty captures the uncertainty in estimating the model parameters , conditioning on training data ( Gal , 2016 ) . This uncertainty can be explained away given enough training data . Data or aleatoric uncertainty is originated from the inherent complexities of the training data , such as class overlap , label noise , homoscedastic and heteroscedastic noise ( Gal , 2016 ) . Distributional uncertainty or dataset shift arises due to the distributional mismatch between the training and test examples ( Quionero-Candela et al. , 2009 ; Malinin & Gales , 2018 ) . In this case , as the network receives unfamiliar out-of-distribution ( OOD ) test data , it should not confidently make predictions . The ability to separately model these three types of predictive uncertainty is important , as it enables the users to take appropriate actions depending on the source of uncertainty . For example , in the active learning scenario , distributional uncertainty indicates that the classifier requires additional data for training . On the other hand , for various real-world applications where the cost of an error is high , such as in autonomous vehicle control , medical , financial and legal fields , the source of uncertainty informs whether an input requires manual intervention . Recently notable progress has been made to detect OOD images . Bayesian neural network based approaches conflate the distributional uncertainty through model uncertainty ( Hernandez-Lobato & Adams , 2015 ; Gal , 2016 ) . However , since obtaining the true posterior distribution for the model parameters are intractable , the success of these approaches depends on the chosen prior distribution over parameters and the nature of approximations . Here , the predictive uncertainties can be measured by using an an ensemble of multiple stochastic forward passes using dropouts from a single DNN ( Monti-Carlo Dropout or MCDP ) ( Gal & Ghahramani , 2016 ) or by ensembling results from multiple DNNs ( Lakshminarayanan et al. , 2017 ) and computing their mean and spread . On the other hand , most of the non-Bayesian approaches model their distributional uncertainty with data uncertainty . These approaches can explicitly train the network in a multi-task fashion incorporating both in-domain and OOD examples to produce sharp and flat predictive posteriors respectively ( Lee et al. , 2018a ; Hendrycks et al. , 2019 ) . However , none of these approaches can robustly determine the source of uncertainty . Malinin & Gales ( 2018 ) introduced Dirichlet Prior Network ( DPN ) to distinctly model the distributional uncertainty from the other uncertainty types . A DPN classifier aims to produce sharp distributions to indicate low-order uncertainty for the in-domain examples and flat distributions for the OOD examples . However , their complex loss function , using the Kullback-Leibler ( KL ) divergence between Dirichlet distributions , results in the error surface to become poorly suited for optimization and makes it difficult efficiently train the DNN classifiers for challenging datasets with a large number of classes ( Malinin & Gales , 2019 ) . In this work , we aim to improve the training efficiency of the DPN framework by proposing a novel loss function that also allows the distributional uncertainty to be modeled distinctly from both data uncertainty and model uncertainty . Instead of explicitly using Dirichlet distributions in the loss function , we propose to apply the standard cross-entropy loss on the softmax outputs along with a novel regularization term for the logit ( pre-softmax activation ) outputs . We train the models in a multi-task function by leveraging both in-domain training images and OOD training images . The proposed loss function can be also viewed from the perspective of the non-Bayesian frameworks ( Lee et al. , 2018a ; Hendrycks et al. , 2019 ) where the proposed regularizer presents an additional term to control the sharpness of the output Dirichlet distributions . In our experiments , we demonstrate that our proposed regularization term can effectively control the sharpness of the output Dirichlet distributions from the DPN to detect distributional uncertainties along with making the framework scalable for more challenging datasets . We also find that the OOD detection performance of our DPN models often improves by augmenting Gaussian noises with the OOD training images to train the DPN . Our experimental results on CIFAR-10 and CIFAR-100 suggest that our proposed approach significantly improves the performance of the DPN framework for OOD detection and out-performs the recently proposed OOD detection techniques . 2 RELATED WORKS . In Bayesian frameworks , the predictive uncertainty of a classification model , trained on a finite dataset , Din = { xi , yi } Ni=1 ∼ Pin ( x , y ) , is expressed in terms of data ( aleatoric ) and model ( epistemic ) uncertainty ( Gal , 2016 ) . For an input x∗ , the predictive uncertainty is expressed as : p ( ωc|x∗ , Din ) = ∫ p ( ωc|x∗ , θ ) p ( θ|Din ) dθ ( 1 ) Here , x and y represents the images and the corresponding class labels , sampled from an underlying probability distribution pin ( x , y ) . Here , the data uncertainty , p ( ωc|x∗ , θ ) is described by the posterior distribution over class labels given model parameters , θ and model uncertainty , p ( θ|Din ) , is given by the posterior distribution over parameters given the data , Din . The expected distribution for predictive uncertainty , p ( ωc|x∗ , Din ) is obtained by marginalizing out θ . However , true posterior for p ( θ|Din ) is intractable . Approaches such as Monte-Carlo dropout ( MCDP ) ( Gal & Ghahramani , 2016 ) , Langevin Dynamics ( Welling & Teh , 2011 ) , explicit ensembling ( Lakshminarayanan et al. , 2017 ) approximate the integral in eq . 1 as : p ( ωc|x∗ , Din ) ≈ 1 M M∑ m=1 p ( ωc|x∗ , θ ( m ) ) θ ( m ) ∼ q ( θ ) ( 2 ) where , θ ( m ) is sampled from an explicit or implicit variational approximation , q ( θ ) of the true posterior p ( θ|Din ) . Each p ( ωc|x∗ , θ ( m ) ) represents a categorical distribution , µ = [ µ1 , · · · , µk ] = [ p ( y = ω1 ) , · · · , p ( y = ωK ) ] over the class labels and the ensemble can be visualized as a collection of points on the simplex . While for a confident prediction , the ensemble is expected to sharply appear in one corner of the simplex , the flatly spread ensembles can not determine whether the uncertainty is due to data or distributional uncertainty . Furthermore , for standard DNNs , with millions of parameters , it becomes even harder to find an appropriate prior distribution and inference scheme to estimate the posterior distribution of the model . Dirichlet Prior Network ( DPN ) is introduced to explicitly model the distributional uncertainty by parameterizing a Dirichlet distribution over a simplex ( Malinin & Gales , 2018 ) . More discussions about DPN is presented in section 3.1 . Alternatively , non-Bayesian frameworks derive their measure of uncertainties using the predictive posteriors obtained from DNNs . Lee et al . ( 2018a ) and Hendrycks et al . ( 2019 ) introduce new components in their loss functions to explicitly incorporate OOD data for training . DeVries & Taylor ( 2018 ) append an auxiliary branch onto a pre-trained classifier to derive the OOD score . Shalev et al . ( 2018 ) uses multiple semantic dense representations as the target label to train the OOD detection network . Several recent works such as ( Lee et al. , 2018b ; Liang et al. , 2018 ) have demonstrated that by tweaking the input images during inference using adversarial perturbations can enhance the performance of a DNN for OOD detection ( Goodfellow et al. , 2014b ) . However , their discriminative scores are achieved by tailoring the parameters for each OOD distributions during test time , which is not possible for real-world OOD examples . Hein et al . ( 2019 ) propose an adversarial training ( Madry et al. , 2018 ) like approach to produce lower confident predictions for OOD examples . However , while these models can identify the total predictive uncertainties , they can not robustly determine whether the source of uncertainty is due to an in-domain input in a region of class overlap or an OOD example far away from the training distribution . 3 PROPOSED METHODOLOGY . This section first describes the DPN framework and the difficulties of the existing modeling techniques to scale DPNs for challenging datasets . We then present our improved version DPN by proposing a novel loss function to address these difficulties while allowing to model the distributional uncertainty distinctly from the model and data uncertainty . 3.1 DIRICHLET PRIOR NETWORK . A DPN for classification directly parametrizes a prior Dirichlet distribution over the categorical output distributions on a simplex ( Malinin & Gales , 2018 ) . For in-domain examples , a DPN attempts to produce sharp Dirichlet in one corner of the simplex , when it is confident in its predictions ( Figure 1a ) . It should produce a sharp distribution in the middle of the simplex to indicate the data ( loworder ) uncertainty for the in-domain example with a high degree of noise or belongs to a class overlapping region ( Figure 1b ) . In contrast , for OOD examples , a DPN should produce a Dirichlet that spreads over the simplex or across the edge of the simplex to indicate the distributional uncertainty ( Figure1c ) . Here , the data uncertainty is expressed by the point-estimate categorical distribution µ while the distributional uncertainty is described using the distribution over the predictive categorical i.e p ( µ|x∗ , θ ) . The overall predictive uncertainty is expressed as : p ( ωc|x∗ , D ) = ∫ ∫ p ( ωc|µ ) p ( µ|x∗ , θ ) p ( θ|D ) dµ dθ ( 3 ) This expression forms a three layered hierarchy of uncertainties : a large model uncertainty , p ( θ|D ) would induce a large variation in distributional uncertainty in p ( µ|x∗ , θ ) and a large degree of uncertainty for µ leads to higher data uncertainty . DPN framework is consistent with the existing approaches , where an additional layer of uncertainty is included to capture the distributional uncertainty . For example , marginalization of µ in Eqn . 3 will reproduce Eqn . 1 while loose the control over the sharpness of the output Dirichlet distributions . The marginalization of θ produces the expected estimation of data and distributional uncertainty given model uncertainty as : p ( ωc|x∗ , D ) = ∫ p ( ωc|µ ) [ ∫ p ( µ|x∗ , θ ) p ( θ|D ) dθ ] dµ = ∫ p ( ωc|µ ) p ( µ|x∗ , D ) dµ ( 4 ) However , similar to eq . 1 marginalizing θ is eq . 4 is also intractable . Since the model uncertainty is reducible given large training data , for simplicity , here we assume a dirac delta estimation , θ̂ for θ : p ( θ|D ) = δ ( θ − θ̂ ) =⇒ p ( µ|x∗ , D ) ≈ p ( µ|x∗ , θ̂ ) ( 5 ) Constructing a DPN . A DPN constructs a Dirichlet distribution as a prior over the categorical distributions , which is parameterized by the concentration parameters , α = α1 , · · · , αK . Dir ( µ|α ) = Γ ( α0 ) ∏K c=1 Γ ( αc ) K∏ c=1 µαc−1c , αc > 0 , α0 = K∑ c=0 αc ( 6 ) where , α0 is called the precision of the Dirichlet . A larger value of α0 produces sharper distributions to indicate low order uncertainties ( fig 1a and 1b ) . A DPN , fθ̂ produces the concentration parameters , α and the posterior over class labels , p ( ωc|x∗ ; θ̂ ) , is given by the mean of the Dirichlet . α = fθ̂ ( x ∗ ) p ( µ|x∗ ; θ̂ ) = Dir ( µ|α ) p ( ωc|x∗ ; θ̂ ) = ∫ p ( ωc|µ ) p ( µ|x∗ ; θ̂ ) dµ = αc α0 ( 7 ) A standard DNN with the softmax activation function can be represented as a DPN where the concentration parameters are αc = ezc ( x ∗ ) ; zc ( x∗ ) is the pre-softmax ( logit ) output corresponding to the class , c for an input x∗ . The expected posterior probability of class label ωc is given as : p ( ωc|x∗ ; θ̂ ) = αc α0 = ezc ( x ∗ ) ∑K c=1 e zc ( x∗ ) ( 8 ) However , the mean of the Dirichlet is now insensitive to any arbitrary scaling of αc . Hence , the precision of the Dirichlet , α0 , degrades under the standard cross-entropy loss . Malinin & Gales ( 2018 ) instead introduced a new loss function that explicitly minimizes the KL divergence between the output Dirichlet and a target Dirichlet to produce a predefined target precision value for the output Dirichlet distributions . For in-domain examples , the target distribution is chosen to be a sharp Dirichlet , Dir ( µ|α̂y ) , focusing on their ground truth classes . While for OOD examples , a flat Dirichlet , Dir ( µ|α̃ ) is selected that spreads over the whole simplex . L ( θ ) = EPinKL [ Dir ( µ|α̂y ) ||p ( µ|x , θ ) ] + EPoutKL [ Dir ( µ|α̃ ) ||p ( µ|x , θ ) ] ( 9 ) where , Pin and Pout are the underlying distribution of in-domain and OOD training examples respectively . However , learning the model using sparse 1-hot continuous distributions for class labels , which are effectively a delta function , is challenging due to their complex loss function ( eq . 9 ) . Here , the error surface becomes poorly suited for optimization using the back-propagation algorithm ( Malinin & Gales , 2019 ) . Malinin & Gales ( 2018 ) tackle this problem by using label smoothing ( Szegedy et al. , 2016 ) or teacher-student training ( Hinton et al. , 2015a ) to redistribute a small amount of probability density to each corner of the Dirichlet . This technique is found to work well for datasets with a fewer number of class labels . However , for more challenging datasets with a large number of classes , even these techniques can not efficiently redistribute the probability densities at each corner and results in the target distribution to tend to a delta function . Hence , it becomes difficult to train the DPN to achieve competitive performances . Malinin & Gales ( 2019 ) have recently proposed to reverse the terms within the KL divergence in eq . 9 to improve the training efficiency of DPN models . This approach still requires to explicitly constrain the precision of the output Dirichlet distributions using an appropriately chosen hyper-parameter for training .

Summary: This work studies the predictive uncertainty issue of deep learning models. In particular, this work focuses on the distributional uncertainty which is caused by distributional mismatch between training and test examples. The proposed method is developed based on the existing work called Dirichlet Prior Network (DPN). It aims to address the issue of DPN that its loss function is complicated and makes the optimization difficult. Instead, this paper proposes a new loss function for DPN, which consists of the commonly used cross-entropy loss term and a regularization term. Two loss functions are respectively defined over in-domain training examples and out-of-distribution (OOD) training examples. The final objective function is a weighted combination of the two loss functions. Experimental study is conducted on one synthetic dataset and two image datasets (CIFAR-10 and CIFAR-100) to demonstrate the properties of the proposed method and compare its performance with the relevant ones in the literature. The issue researched in this work is of significance because understanding the predictive uncertainty of a deep learning model has its both theoretical and practical value. The motivation, research issues and the proposed method are overall clearly presented.