Bayesian Neural Networks with Variance Propagation for Uncertainty Evaluation

1 INTRODUCTION . Uncertainty evaluation is a core technique in practical applications of deep neural networks ( DNNs ) . As an example , let us consider the Cyber-Physical Systems ( CPS ) such as the automated driving system . In the past decade , machine learning methods are widely utilized to realize the environment perception and path-planing components in the CPS . In particular , the automated driving system has drawn a huge attention as a safety-critical and real-time CPS ( NITRD CPS Senior Steering Group , 2012 ; Wing , 2009 ) . In the automated driving system , the environment perception component is built using DNN-based predictive models . In real-world applications , the CPS is required to deal with unexpected samples that have not seen in the training process . Therefore , not only achieving the high-prediction accuracy under the ideal environment but providing uncertainty evaluation for real-world data is significant for safety-critical systems ( Henne et al. , 2019 ) . The CPS should prepare some options such as the rejection of the recommended action to promote the user ’ s intervention when the uncertainty is high . Such an interactive system is necessary to build fail-safe systems ( Varshney & Alemzadeh , 2017 ; Varshney , 2016 ) . On the other hand , the uncertainty evaluation is useful to enhance the efficiency of learning algorithms , i.e. , samples with high uncertainty are thought to convey important information for training networks . Active data selection based on the uncertainty has been studied for long time under the name of active learning ( David et al. , 1996 ; Gal et al. , 2017 ; Holub et al. , 2008 ; Li & Guo , 2013 ; Shui et al. , 2020 ) . In statistics and machine learning , Bayesian estimation has been commonly exploited for uncertainty evaluation ( Bishop , 2006. ) . In the Bayesian framework , the prior knowledge is represented as the prior distribution of the statistical model . The prior distribution is updated to the posterior distribution based on observations . The epistemic model uncertainty is represented in the prior distribution , and upon observing data , those beliefs can be updated in the form of a posterior distribution , which yields model uncertainty conditioned on observed data . The entropy or the variance is representative of uncertainty measures ( Cover & Thomas , 2006 ) . For complicated models such as DNNs , however , a direct application of Bayesian methods is prohibited as the computation including the high-dimensional integration highly costs . In deep learning , Bayesian methods are related to stochastic learning algorithms . This relation is utilized to approximate the posterior over complex models . The stochastic method called dropout is a powerful regularization method for DNNs ( Srivastava et al. , 2014 ) . In each layer of the DNN , some units are randomly dropped in the learning using stochastic gradient descent methods . Gal & Ghahramani ( 2016a ) revealed that the dropout is interpreted as the variational Bayes method . Based on this interpretation , they proposed a simple sampling method of DNN parameters from the approximate posterior distribution . Furthermore , the uncertainty of the DNN-based prediction is evaluated using the Monte-Carlo ( MC ) method called MC dropout . While the Bayesian DNN trained using dropout is realized by a simple procedure , the computational overhead is not ignorable . In the MC dropout , dropout is used also at the test time with a number of repeated feed-forward calculations to effectively sample from the approximate posterior . Hence , the naive MC dropout is not necessarily relevant to the system demanding the real-time response . In this work , we propose a sampling-free method to evaluate the uncertainty of the DNN-based prediction . Our method is computationally inexpensive comparing to the MC dropout and provides reliable uncertainty evaluation . In the following , we will first outline related works . Section 3 is devoted to show the detailed formulae of calculating the uncertainty . In our method , an upper bound of the variance is propagated in each layer to evaluate the uncertainty of the output . We show that the our method alleviates the overconfident prediction . This property is shared with scaling methods for the calibration of the class-probability on test samples . In Section 4 , we study the relation between our method and scaling methods . In Section 5 , we demonstrate the computational efficiency and statistical reliability of our method through some numerical experiments using both DNNs and RNNs . 2 RELATED WORKS . The framework of Bayesian inference is often utilized to evaluate the uncertainty of DNN-based predictions . In Bayesian methods , the uncertainty is represented by the predictive distribution defined from the posterior distribution of the weight parameters . MacKay ( 1992 ) proposed a simple approximation method of the posterior distribution for neural networks , and demonstrated that the Bayesian method improves the prediction performance on classification tasks . Graves ( 2011 ) showed that the variational method efficiently works to approximate the posterior distribution of complex neural network models . There are many approaches to evaluate the uncertainty of modern DNNs ( Alex Kendall & Cipolla , 2017 ; Choi et al. , 2018 ; Lu et al. , 2017 ; Le et al. , 2018 ) . We briefly review MC-based methods and sampling-free methods . Monte-Carlo methods based on Stochastic Learning : The randomness in the learning process can be interpreted as a prior distribution . In particular , the dropout is a landmark of stochastic regularization method to train DNNs ( Srivastava et al. , 2014 ) . Gal & Ghahramani ( 2016a ) proposed a simple method to generate weight parameters from the posterior distribution induced from the prior corresponding to the dropout regularization . The predictive distribution is approximated by the MC dropout , which compute the expected output over the Monte-Carlo sampling of the weight parameters . Gal & Ghahramani ( 2016b ) reported that the MC dropout efficiently works not only for feed-forward DNNs but for recurrent neural networks ( RNNs ) . Another sampling based method is the ensemble-based posteriors with different random seeds ( Lakshminarayanan et al. , 2017 ) . However , the computation cost is high as the bootstrap method requires repeated training of parameters using resampling data . Sampling-free methods : Though the MC dropout is a simple and practical method to evaluate the uncertainty , a number of feed-forward computations are necessary to approximate the predictive distribution . Recently , some sampling-free methods have been proposed for the uncertainty evaluation . Probabilistic network is a direct way to deal with uncertainty . The parameters of the probabilistic model , say the mean and the variance of the Gaussian distribution , are propagated in probabilistic neural networks . Then , the uncertainty evaluation is given by a single feed-forward calculation . Choi et al . ( 2018 ) used the mixture of Gaussian distributions as a probabilistic neural network and Wang et al . ( 2016 ) proposed natural-parameter networks as a class of probabilistic neural networks based on exponential families . For a given input vector , the network outputs the parameters of the distribution . For the recurrent neural networks , Hwang et al . ( 2019 ) proposed a variant of the natural-parameter networks . Instead of parameters of statistical models , Wu et al . ( 2019 ) developed a sampling-free method to propagate the first and second order moments of the posterior distribution . Sampling-free methods can evaluate the uncertainty with a one-pass computation for neural networks . However , specialized learning algorithms are required to train the probabilistic networks . Our method is applicable to DNNs and RNNs trained by common learning methods with the dropout . Postels et al . ( 2019 ) and Shekhovtsov & Flach ( 2019 ) proposed similar methods that propagate the uncertainty of the network to the output layer . Differently from the past works , our method takes the upper limit of the correlations among the inputs at the affine layer into account when the uncertainty is evaluated . In addition , we show that our method efficiently works even for RNNs . 3 UNCERTAINTY EVALUATION WITH VARIANCE PROPAGATION . In this work , we assume that we can access to the weight parameters in the DNN and the dropout probability in the training process . As the variance is a common measure of uncertainty , we propose a variance propagation algorithm for the trained DNN . Implementation of our method called nn2vpbnn is presented in Section A in the appendix . In our method , we need only the DNN or RNN trained using dropout . Unlike various kinds of probabilistic NNs , we do not need any specialized training procedure to evaluate the uncertainty . This is a great advantage for our implementation . Furthermore , the representative values of the predictive distribution , i.e . the mean and variance , are obtained by a one-path feed-forward calculation . Hence , we can circumvent iterative Monte-Carlo calculations . 3.1 UNCERTAINTY IN AFFINE LAYER . Let us consider the output of the affine layer y = Wx + b for the random input x , where W = ( Wij ) ∈ R ` ×m and b = ( bi ) ` i=1 ∈ R ` . Suppose that the random vector x has the mean vector E [ x ] and the variance covariance matrix ( Σx ) i , j = Cov ( xi , xj ) for i , j = 1 , . . . , m. Then , the mean vector E [ y ] and the variance covariance matrix Σy of y are given by E [ y ] = WE [ x ] + b and Σy = WΣxW T . As the estimation of the full variable-covariance matrix is not necessarily reliable , we use only the variances of each xi and an upper bound of the absolute correlation coefficient to evaluate the uncertainty . For W = ( Wij ) , the variance Var [ yi ] is Var [ yi ] = ∑ jW 2 ijVar [ xj ] +∑ j , j′ : j 6=j′WijWij′Cov ( xj , xj′ ) . Suppose the absolute correlation coefficient among x1 , . . . , xm is bounded above by ρ , 0 ≤ ρ ≤ 1 . Using the relation between the correlation and variance , we have Var [ yi ] ≤ ∑ j W 2ijVar [ xj ] + ρ ∑ j , j′ : j 6=j′ |Wij ||Wij′ | √ Var ( xj ) √ Var ( xj′ ) = ( 1− ρ ) ∑ j |Wij |2Var [ xj ] + ρ ( ∑ j |Wij | √ Var ( xj ) ) 2 , i = 1 , . . . , ` . ( 1 ) Under the independent assumption , i.e. , ρ = 0 , the minimum upper bound is obtained . The prediction with a small variance leads to overconfident decision making . Hence , the upper bounding of the variance is important to build fail-safe systems . A simple method of estimating ρ is presented in Section 3.5 . Using the above formula , the mean and an upper bound of the variance of y are computed using the mean and an upper bound of the variance of x . In this paper , such a computation is referred to as the Variance Propagation or VP for short . Let us define the variance vector of the m-dimensional random vector x = ( x1 , . . . , xm ) ∈ Rm by Var [ x ] = ( Var [ x1 ] , . . . , Var [ xm ] ) ∈ Rm . Furthermore , we denote the concatenated vector of the mean and variance of z or its approximation as U ( z ) , i.e. , U ( z ) = ( E [ z ] , Var [ z ] ) . The VP at the affine layer is expressed by the function Taff , U ( y ) = ( m , v ) = Taff ( U ( x ) ) , ( 2 ) where m = WE [ x ] + b ∈ Rm and each element of v ∈ Rm is defined by equation 1 . The average pooling layer , global average pooling layer ( Lin et al. , 2013 ) , and the batch normalization layer ( Ioffe & Szegedy , 2015 ) are examples of the affine layer . Hence , the VP of the affine layer also works to evaluate the uncertainty of these layers . The distribution of yi is well approximated by the univariate Gaussian distribution if the correlation among x is small ( Wang & Manning , 2013 ; Wu et al. , 2019 ) . Based on this fact , the uncertainty of yi can be represented by the univariate Gaussian distribution N ( E [ yi ] , Var [ yi ] ) . In our method , the variance Var [ yi ] of the approximate Gaussian is given by the variance v in equation 2 .

Summary: This paper proposes a sampling free technique based on variance propagation to model predictive distributions of deep learning models. Estimating uncertainty of deep learning models is an important line of research for understanding the reliability of predictions and ensuring robustness to out-of-distribution data. Results are shown using synthetic data, perplexity analysis for a language modeling task and out-of-distribution detection performance using a convolutional network.