Title: ACCELERATING MONTE CARLO BAYESIAN PREDIC-TION VIA APPROXIMATING PREDICTIVE UNCER-TAINTY OVER THE SIMPLEX

Abstract: Estimating the predictive uncertainty of a Bayesian learning model is critical in various decision-making problems, e.g., reinforcement learning, detecting adversarial attack, self-driving car. As the model posterior is almost always intractable, most efforts were made on finding an accurate approximation the true posterior. Even though a decent estimation of the model posterior is obtained, another approximation is required to compute the predictive distribution over the desired output. A common accurate solution is to use Monte Carlo (MC) integration. However, it needs to maintain a large number of samples, evaluate the model repeatedly and average multiple model outputs. In many real-world cases, this is computationally prohibitive. In this work, assuming that the exact posterior or a decent approximation is obtained, we propose a generic framework to approximate the output probability distribution induced by model posterior with a parameterized model and in an amortized fashion. The aim is to approximate the true uncertainty of a specific Bayesian model, meanwhile alleviating the heavy workload of MC integration at testing time. The proposed method is universally applicable to Bayesian classification models that allow for posterior sampling. Theoretically, we show that the idea of amortization incurs no additional costs on approximation performance. Empirical results validate the strong practical performance of our approach. Θ Cat(y|T x * (θ))p(θ|D) dθ = S K-1 Cat(y|π)p x * (π) dπ.
(2)

1. INTRODUCTION:

Bayesian inference is a principled method to estimate the uncertainty of probabilistic models. In most applications, especially in deep learning, the likelihood model and model prior are not conjugate hence marginalizing over model prior or posterior cannot be performed analytically, which hinders the practical applicability. For tractability, a simple point estimate such as maximum a posteriori (MAP) estimate could be used to approximate the full model posterior. The price paid is the loss of model uncertainty due to incomplete characterization of the model posterior. Approximate inference methods, such as Markov chain Monte Carlo and variational inference, enhance the approximate posterior by a better probability distribution while keeping inference tractability. However, even though a decent approximation of posterior can be obtained, computation of predictive distribution is usually intractable due to loss of conjugacy, and is of high cost if tractable.

To introduce the problem, we consider a Bayesian classification model trained on dataset D = {(y n , x n )} N n=1 , where x n ∈ X and y n ∈ Y are the nth input and output, respectively. Let the model posterior p(θ|D) be approximated by MC estimate 1 S S s=1 δ(θθ s ), and the predictive distribution (a categorical distribution parameterized by the predicted class probabilities) is thus approximated by p(y|x, D) = p(y|x, θ)p(θ|D) dθ ≈ 1 S S s=1 p(y|x, θ s ).

The predictive distribution can be accurately estimated as S → ∞. However, to perform the computation, we need to maintain a large number of samples, repeatedly evaluate the model for S times and finally average the model outputs. This problem is critical in many real-world cases. For example, assisted-driving car system requires an accurate measure of uncertainty to avoid making mistakes with a high confidence (Kendall & Gal, 2017; Sünderhauf et al., 2018) . Due to the limited computational resources and storage in such system, it's hard to maintain a large number of samples and perform S times evaluation of the Bayes model for the real-time image data.

In this work, aiming at boosting the prediction speed while maintaining a rich characterization of the prediction, we propose to approximate the distribution of class probabilities over the simplex induced by the model posterior p(θ|D), in an amortized fashion. This naturally diverts the heavy-load MC integration process from testing period to approximation period. Different from the previous work in Bayesian knowledge distillation (Balan et al., 2015; Bulò et al., 2016) that only focuses on the output categorical distribution (a point on simplex), the induced distribution over simplex provides: 1) rich knowledge includes prediction confidence for identifying out-of-domain (OOD) data (see empirical examples in Fig. 2 ); 2) the possibility to use more expressive distributions as the approximate model.

We term the Bayes classifier as "Bayes teacher" and the approximate distribution as "student", due to the analogy with teacher-student learning. A Dirichlet distribution is used as the student due to its expressiveness, conjugacy to categorical distribution and its efficient reparameterization for training.

We propose to explicitly disentangle the parameters of the student into a prediction model (PM) and concentration model (CM), which capture class probability and sharpness of Dirichlet respectively. The CM output can directly be used as a measure for detecting OOD data. We term our approximation method as One-Pass Uncertainty (OPU) as it simplifies real-world evaluation of Bayesian models by computing the predictive distribution with only one model evaluation. Note that, OPU allows choosing various types of student model (e.g., compressed neural network (Lin et al., 2017; Hubara et al., 2016; Han et al., 2015) ) for further speedup on specific platforms with no extra design efforts.

As the amortized approximation of induced distributions is unexplored in the literature, we consider and compare several choices of probability distance measure: forward KL, earth-mover's distance (EMD) and maximum mean discrepancy (MMD). We theoretically analyze the performance gap incurred by the amortized approximation and show that, under MMD, besides model loss due to restriction of student distribution, the amortized approximation does not introduce additional loss. Empirical evaluations show a significant speedup (∼ 500×) of Bayes models. The results on Bayes NN show that OPU performs better in misclassification detection and OOD detection than state-ofthe-art works in Bayesian knowledge distillation. It can also be observed that explicit disentangling of mean and concentration helps improve the performance. The comparisons of different probability measures validate the theoretical analysis. We also conduct empirical evaluations and comparisons on Bayes logistic regression and Gaussian process, to show OPU is universally applicable to all Bayesian classification models.

2 ONE-PASS UNCERTAINTY FRAMEWORK

2.1. INDUCED DISTRIBUTION OVER SIMPLEX:

In this section we present our OPU framework for a generic Bayesian parametric classifier, e.g. Bayesian logistic regression (BLR) or Bayesian neural networks (NN). Let the Bayesian classifier be specified with categorical likelihood and a parametric function, i.e., p(y|x, θ) = Cat(y|T (x; θ))

and a prior distribution p(θ) be specified over the parameter space Θ, where T : X × Θ → S K-1 is a parametric function from input space to simplex, e.g., a neural network with softmax output layer, and K is the number of classes. In this paper, we assume the posterior p(θ|D) is obtained and focus on the computation of the predictive distribution. In what follows, let p(θ|D) be approximate or exact (if available) model posterior, from which samples could be obtained. From a dual perspective, with a fixed input x, the mapping T x = T (x; •) is also understood as a data-dependent mapping T x : Θ → S K-1 , which could be used to transform the posterior p(θ|D) to a conditional distribution (on x) over the simplex. That is, for each x, we can define a random variable π = T x (θ) whose distribution is induced by θ ∼ p(θ|D) and T x . This is effectively a welldefined push-forward measure T x #p(θ|D) over the simplex (see Fig. 1 ). We term the conditional distribution of π|x, D as an "induced distribution" and define p x (π) = p(π|x, D) to keep the notation uncluttered.

The induced distribution isolates the dependence between input and output and simplifies the computation of predictive distribution due to the change-of-variable formula. Specifically, given a test point x * , the predictive distribution can be alternatively written as 

p(y|x * , D) = Softmax T x < l a t e x i t s h a 1 _ b a s e 6 4 = " 7 o v A z K A S R 5 u B M g Y + w X k f D E 2 f 8 a I = " > A A A C A X i c b V D L S s N A F L 2 p r 1 p f U T e C m 8 E i u C p J F X R Z d O O y Q l / Q h j K Z T t q h k w c z E 7 G E u P F X 3 L h Q x K 1 / 4 c 6 / c Z J m o a 0 H B s 6 c c y / 3 3 u N G n E l l W d 9 G a W V 1 b X 2 j v F n Z 2 t 7 Z 3 T P 3 D z o y j A W h b R L y U P R c L C l n A W 0 r p j j t R Y J i 3 + W 0 6 0 5 v M r 9 7 T 4 V k Y d B S s 4 g 6 P h 4 H z G M E K y 0 N z a O B j 9 W E Y J 6 0 0 m G S f 1 w v e U j T o V m 1 a l Y O t E z s g l S h Q H N o f g 1 G I Y l 9 G i j C s Z R 9 2 4 q U k 2 C h G O E 0 r Q x i S S N M p n h M + 5 o G 2 K f S S f I L U n S q l R H y Q q F f o F C u / u 5 I s C / l z H d 1 Z b a i X P Q y 8 T + v H y v v y k l Y E M W K B m Q + y I s 5 U i H K 4 k A j J i h R f K Y J J o L p X R G Z Y I G J 0 q F V d A j 2 4 s n L p F O v 2 e e 1 + t 1 F t X F d x F G G Y z i B M 7 D h E h p w C 0 1 o A 4 F H e I Z X e D O e j B f j 3 f i Y l 5 a M o u c Q / s D 4 / A G 5 v J e 2 < / l a t e x i t > ✓ ⇠ p(✓|D) < l a t e x i t s h a 1 _ b a s e 6 4 = " f q R R p J e k f m u D V u n m H Z W 3 i A R b i 1 U = " > A A A C I 3 i c d V D L T g I x F O 3 4 R H y h L t 0 0 E h P c k A 4 o i C u i L l x i I k j C E N I p B R o 7 j 7 R 3 T M j I v 7 j x V 9 y 4 0 B A 3 L v w X O 4 C J G r x J 0 5 N z 7 s 0 9 9 7 i h F B o I + b A W F p e W V 1 Z T a + n 1 j c 2 t 7 c z O b k M H k W K 8 z g I Z q K Z L N Z f C 5 3 U Q I H k z V J x 6 r u S 3 7 t 1 F o t / e c 6 V F 4 N / A M O R t j / Z 9 0 R O M g q E 6 m T P H D W R X D z 3 z x Q 4 M O N C R o 4 W H w 9 w c 5 c H x K A w Y l f H l 6 K i T y Z J 8 q V I q n F Q w y R N C S k X b A J u c l s t F b C e M q S y a V a 2 T G T v d g E U e 9 4 F J q n X L J i G 0 Y 6 p A M M l H a S f S P K T s j v Z 5 y 0 C f e l y 3 4 8 m N I 3 x o m C 7 u B c o 8 H / C E / T k R U 0 8 n Z k 1 n 4 l H / 1 R J y n t a K o H f a j o U f R s B 9 N l 3 U i y S G A C e B 4 a 5 Q n I E c G k C Z E s Y r Z g O q K A M T a 9 q E 8 H 0 p / h 8 0 C n m 7 m C 9 c H 2 e r 5 7 M 4 U m g f H a A c s l E Z V d E V q q E 6 Y u g R P a N X 9 G Y 9 W S / W 2 H q f t i 5 Y s 5 k 9 9 K u s z y + C S a a q < / l a t e x i t > ⇡ 1 < l a t e x i t s h a 1 _ b a s e 6 4 = " B t I b 7 k J m f J s N Z C m v q 0 + B v R o H k N c = " > A A A B + 3 i c d V B L S w M x G M z W V 6 2 v W o 9 e g k X w t G R b 7 e N W 9 O K x g n 1 A u y z Z b N q G Z r N L k h X L 0 r / i x Y M i X v 0 j 3 v w 3 Z t s K K j o Q M s x 8 H 5 m M H 3 O m N E I f V m 5 t f W N z K 7 9 d 2 N n d 2 z 8 o H p a 6 K k o k o R 0 S 8 U j 2 f a w o Z 4 J 2 N N O c 9 m N J c e h z 2 v O n V 5 n f u 6 N S s U j c 6 l l M 3 R C P B R s x g r W R v G J p 6 E c 8 U L P Q X O k w Z n P P 8 Y p l Z N e a t c p F E y I b I V S r O o Y 4 q F G v V 6 G T K Q Z l s E L b K 7 4 P g 4 g k I R W a c K z U w E G x d l M s N S O c z g v D R N E Y k y k e 0 4 G h A o d U u e k i + x y e G i W A o 0 i a I z R c q N 8 3 U h y q L J 6 Z D L G e q N 9 e J v 7 l D R I 9 a r g p E 3 G i q S D L h 0 Y J h z q C W R E w Y J I S z W e G Y C K Z y Q r J B E t M t K m r Y E r 4 + i n 8 n 3 Q r t l O 1 K z f n 5 d b l q o 4 8 O A Y n 4 A w 4 o A 5 a 4 B q 0 Q Q c Q c A 8 e w B N 4 t u b W o / V i v S

A k = " > A A A B + 3 i c d V B L S w M x G M z W V 6 2 v t R 6 9 B I v g a c l u t Y 9 b 0 Y v H C v Y B 3 V K y 2 W w b m n 2 Q Z M W y 9 K 9 4 8 a C I V / + I N / + N 2 b a C i g 6 E D D P f R y b j J Z x J h d C H U V h b 3 9 j c K m 6 X d n b 3 9 g / M w 3 J X x q k g t E N i H o u + h y X l L K I d x R S n / U R Q H H q c 9 r z p V e 7 3 7 q i Q L I 5 u 1 S y h w x C P I x Y w g p W W R m b Z 9 W L u y 1 m o r 8 x N 2 H z k j M w K s m r N m n P R h M h C C N W q t i Y 2 a t T r V W j n i k Y F r N A e m e + u H 5 M 0 p J E i H E s 5 s F G i h h k W i h F O 5 y U 3 l T T B Z I r H d K B p h E M q h 9 k i + x y e a s W H Q S z 0 i R R c q N 8 3 M h z K P J 6 e D L G a y N 9 e L v 7 l D V I V N I Y Z i 5 J U 0 Y g s H w p S D l U M 8 y K g z w Q l i s 8 0 w U Q w n R W S C R a Y K F 1 X S Z f w 9 V P 4 P + k 6 l l 2 1 n J v z S u t y V U c R H I M T c A Z s U A c t c

h U L B K 3 e h p T N 8 Q j w Q J G s D b S s F B 0 v I j 7 a h q a K 3 V i N h v e D A s l V K 4 1 a 5 X z J k R l h F C t a h t i o 0 a 9 X o V 2 p h i U w B L t Y

i B / 1 H N D O d R T 3 1 x J D 8 Y c 6 G x Q H O Q L x C 7 X y s W L G i Y 2 I a R c c g x x S L V S K W E n V Q w K a I n G I P / e G 4 Y s 9 n k A T F K t u w 6 J o J 9 Q B Y J J P s v 1 Y s 0 j y i Z 0 x L u G B t T n u p / M 4 8 / w q V G G 2 A u V O Q H g u f p 9 I 6 G + T h O a S Z / C W P / 2 U v E v r x u D V + 0 n I o h i 4 A F b P O T F E k O I 0 y 7 w U C j O Q E 4 N o U w J k x W z M V W U g W k s Z 0 r 4 + i n + n 7 S K t l O y i z f n h f r l s o 4 s O k Y n 6

A w 5 q I L q 6 B o 1 U B M x l K A H 9 I S e r X v r 0 X q x X h e j G W u 5 c 4 h + w H r 7 B E b H l l g = < / l a t e x i t > ✓ S < l a t e x i t s h a 1 _ b a s e 6 4 = " 3 b L x h Y d a d n O 7 q I j a j L u 7 7 Y B v w 9 E = " > A A A B / n i c d V D L S g M x F M 3 U V 6 2 v q r h y E y y C q y H T a h Our key insight is that p x contains all information we need for prediction and uncertainty measurement. Hence π is sufficient in the sense that, given π, y is independent of both θ and x. The isolation combines the complexities in both the likelihood and posterior into a single object p x , and keeps a simple dependence structure between y and π. Also, the isolation renders the last probabilistic layer y|π nuisance, which can thus be peeled off for prediction. To validate the idea, one can show that the predictive distribution is simply p(y|x, D) = Cat(y|E px π). The difference between probabilistic structures of original Bayesian model and the isolated version is showed in Fig. 3 , Appendix.

+ 7 o h u X F W 0 t t K V k M m k b m n m Q 3 B H K U P B X 3 L h Q x K 3 f 4 c 6 / M d N W U N E D I Y d z 7 i U n x 4 2 k 0 E D I h 5 V Z W l 5 Z X c u u 5 z Y 2 t 7 Z 3 8 r t 7 L R 3 G i v E m C 2 W o 2 i 7 V X I q A N 0 G A 5 O 1 I c e q 7 k t + 6 4 4 v U v 7 3 j S o s w u I F J x H s + H Q Z i I B g F I / X z B 1 0 3 l J 6 e + O Z K u j D i Q K f 9 6 3 6 + Q O x y r V w 8 q 2 F i E 0 L K J c c Q h 1 Q r l R J 2 U s W g g B Z o 9 P P v X S 9 k s c 8 D Y J J q 3 X F I B L 2 E K h B M 8 m m u G 2 s e U T a m Q 9 4 x N K A + 1 7 1 k F n + K j 4 3 i 4 U G o z A k A z 9 T v G w n 1 d Z r Q T P o U R v q 3 l 4 p / e Z 0 Y B t V e I o I o B h 6 w + U O D W G I I c d o F 9 o T i D O T E E M q U M F k x G 1 F F G Z j G c q a E r 5 / i / 0 m r a D s l u 3 h 1 W q i f L + r I o k N 0 h E 6 Q g y q o j i 5 R A z U R Q w l 6 Q E / o 2 b q 3 H q 0 X 6 3 U + m r E W O / v

M V + E h m 4 W j F y x o s A q F 0 r l C j R 1 Y 6 o M m K v W S 3 9 0 + j 4 O X e J J z J A Q b d M I Z D d C X F L M S J z q h I I E C I / Q g L Q V e s g l o h t N b 4 r h k X L 6 0 P G 5 e p 6 E U / f 7 R I R c I c a u r T o n O 4 r f t Y n 5 V 6 0 d S q f c j a g X h J J 4 e P a R E z I o f T g J C P Y p J 1 i y s Q K E O V W 7 Q j x E H G G p Y k y p E B a X w v + h k d N N S 8 9 d 5 T P V s 3 k c S X A A D k E W m K A E q u A S 1 E A d Y H A P H s E z e N E e t C f t V X u b t S a 0 + c w + + C H t / Q s Y 3 5 + R < / l a t e x i t > x < l a t e x i t s h a 1 _ b a s e 6 4 = " v d z m A T c 8 T M U q F F 5 A v Q u f O l J f X J s = " > A A A B 8 X i c d V D L S g M x F L 3 j s 9 Z X 1 a W b Y B F c D Z l x q F 0 W 3 b i s Y B / Y l p J J M 2 0 w k x m S j F i G / o U b F 4 q 4 9 W / c + T e m D 0 F F D w Q O 5 9 x L z j 1 h K r g 2 G H 8 4 S 8 s r q 2 v r h Y 3 i 5 t b 2 z m 5 p b 7 + p k 0 x R 1 q C J S F Q 7 J J o J L l n D c C N Y O 1 W M x K F g r f D 2 Y u q 3 7 p j S P J H X Z p y y X k y G k k e c E m O l m 2 5 M z C i M 8 v t J v 1 T G L v Z x t V J B 2 P W 9 I M C B J U H F P / V 9 5 L l 4 h j I s U O + X 3 r u D h G Y x k 4 Y K o n X H w 6 n p 5 U Q Z T g W b F L u Z Z i m h t 2 T I O p Z K E j P d y 2 e J J + j Y K g M U J c o + a d B M / b 6 R k 1 j r c R z a y W l C / d u b i n 9 5 n c x E 1 V 7 O Z Z o Z J u n 8 o y g T y C R o e j 4 a c M W o E W N L C F X c Z k V 0 R B S h x p Z U t C V 8 X Y r + J 0 3 f 9 U 5 d / y o o 1 8 4 X d R T g E I 7 g B D w 4 g x p c Q h 0 a Q E H C A z z B s 6 O d R + f F e Z 2 P L j m L n Q P 4 A e f t E 0 + r k V g = < /

= " > A A A C B 3 i c d V D L S g M x F M 3 U V 6 2 v U Z e C B I t Q N y X T a h + 7 o h u X F e w D O q V k 0 k w b m n m Y Z M Q y d u f G X 3 H j Q h G 3 / o I 7 / 8 Z M W 0 F F L 4 Q c z r m X e + 5 x Q s 6 k Q u j D S C 0 s L i 2 v p F c z a + s b m 1 v m 9 k 5 T B p E g t E E C H o i 2 g y X l z K c N x R S n 7 V B Q 7 D m c t p z R W a K 3 r q m Q L P A v 1 T i k X Q 8 P f O Y y g p W m e u b + V c 5 2 A t 6 X Y 0 9 / s R 2 y y a 3 t Y T V 0 3 P h m c t Q z s y h f q p Y K J 1 W I 8 g i h U t H S w E K V c r k I r Y T R l Q X z q v f M d 7 s f k M i j v i I c S 9 m x U K i 6 M R a K E U 4 n G T u S N M R k h A

= " > A A A B 8 X i c d V B N S w M x F H x b v 2 r 9 q n r 0 E i y C p y W 7 X W q P R S 8 e K 1 g t t q V k 0 6 w N Z r N L k h X K 0 n / h x Y M i X v 0 3 3 v w 3 Z t s K K j o Q G G b e I / M m T A X X B u M P p 7 S 0 v L K 6 V l 6 v b G x u b e 9 U d / e u d J I p y j o 0 E Y n q h k Q z w S X r G G 4 E 6 6 a K k T g U 7 D q 8 O y v 8 6 3 u m N E / k p Z m k b B C T W 8 k j T o m x 0 k 0 / J m Y c R v l 4 O q z W s I t 9 3 G w 0 E H Z 9 L w h w Y E n Q 8 O u + j z w X z 1 C D B d r D 6 n t / l N A s Z t J Q Q b T u e T g 1 g 5 w o w 6 l g 0 0 o / 0 y w l 9 I 7 c s p 6 l k s R M D / J Z 4 i k 6 s s o I R Y m y T x o 0 U 7 9 v 5 C T W e h K H d r J I q H 9 7 h f i X 1 8 t M 1 B z k X K a Z Y Z L O P 4 o y g U y C i v P R i C t G j Z h Y Q q j i N i u i Y 6 I I N b a k i i 3 h 6 1 L 0 P 7 n y X a / u + h d B r X W 6 q K M M B 3 A I x + D B C b T g H N r Q A Q o S H u A J n h 3 t P D o v z u t 8 t O Q s d v b h B 5 y 3 T z d b k U g = < / l a t e x i t > Scalar g < l a t e x i t s h a 1 _ b a s e 6 4 = " L A Q D U t I 3 n q H o S H u W I T B B R k 0 Z d Q M = " > A A A B 6 H i c d V D L S g N B E O y N r x h f U Y 9 e B o P g a Z n d L D H H o B e P C Z g Y S J Y w O 5 l N x s w + m J k V w p I v 8 O J B E a 9 + k j f / x s l D U N G C h q K q m + 6 u I B V c a Y w / r M L a + s b m V n G 7 t L O 7 t 3 9 Q P j z q q C S T l L V p I h L Z D Y h i g s e s r b k W r J t K R q J A s N t g c j X 3 b + + Z V D y J b / Q 0 Z X 5 E R j E P O S X a S K 3 R o F z B N n Z x v V Z D 2 H Y d z 8 O e I V 7 N r b o u c m y 8 Q A V W a A 7 K 7 / 1 h Q r O I x Z o K o l T P w a n 2 c y I 1 p 4 L N S v 1 M s Z T Q C R m x n q E x i Z j y 8 8 W h M 3 R m l C E K E 2 k q 1 m i h f p / I S a T U N A p M Z 0 T 0 W P 3 2 5 u J f X i / T Y d 3 P e Z x m m s V 0 u S j M B N I J m n + N h l w y q s X U E E I l N 7 c i O i a S U G 2 y K Z k Q v j 5 F / 5 O O a z t V 2 2 1 5 l c b l K o 4 i n M A p n I M D F 9 C A a 2 h C G

M U q F F 5 A v Q u f O l J f X J s = " > A A A B 8 X i c d V D L S g M x F L 3 j s 9 Z X 1 a W b Y B F c D Z l x q F 0 W 3 b i s Y B / Y l p J J M 2 0 w k x m S j F i G / o U b F 4 q 4 9 W / c + T e m D 0 F F D w Q O 5 9 x L z j 1 h K r g 2 G H 8 4 S 8 s r q 2 v r h Y 3 i 5 t b 2 z m 5 p b 7 + p k 0 x R 1 q C J S F Q 7 J J o J L l n D c C N Y O 1 W M x K F g r f D 2 Y u q 3 7 p j S P J H X Z p y y X k y G k k e c E m O l m 2 5 M z C i M 8 v t J v 1 T G L v Z x t V J B 2 P W 9 I M C B J U H F P / V 9 5 L l 4 h j I s U O + X 3 r u D h G Y x k 4 Y K o n X H w 6 n p 5 U Q Z T g W b F L u Z Z i m h t 2 T I O p Z K E j P d y 2 e J J + j Y K g M U J c o + a d B M / b 6 R k 1 j r c R z a y W l C / d u b i n 9 5 n c x E 1 V 7 O Z Z o Z J u n 8 o y g T y C R o e j 4 a c M W o E W N L C F X c Z k V 0 R B S h x p Z U t C V 8 X Y r + J 0 3 f 9 U 5 d / y o o 1 8 4 X d R T g E I 7 g B D w 4 g x p c Q h 0 a Q E H C A z z B s 6 O d R + f F e Z 2 P L j m L n Q P 4 A e f t E 0 + r k V g = < /

Although the density function p x is sometimes hard to compute, especially for complicated T x (like NN), its samples can be obtained via 1) sampling the posterior, i.e. θ s ∼ p(θ|D); 2) "push-forward" the samples by T x , i.e. π s = T x (θ s ). The behavior of π can be empirically observed via the particles {π s } S s=1 . As shown in Fig. 2 , π is able to distinguish different types of input x based on the behavior of its samples. In Fig. 2 (a), the inputs are similar to the training data. The particles gather around a corner of the simplex, indicating a confident prediction. In Fig. 2 (b), the inputs are digit images but are relatively hard to predict. Therefore, the particles gathers around the center, indicating the model is certain that the input is on decision boundary. In Fig. 2(c ), the inputs are images outside the domain of training data, the particles spread over the simplex, which means the model has a high uncertainty about input, indicating out-of-domain (OOD). In Fig. 2(d) , the particles spread along a line between two corners, indicating the model is confident that the result is not at the other corner.

However, using particles for inference is time-consuming as each particle requires one evaluation of the model. This motivates us to use a tractable conditional distribution q(π|x) to approximate p x .

2.2. AMORTIZED APPROXIMATION:

The view of p x enables flexible choices of q(π|x), as any distribution defined on R K can be transformed to S K-1 via logistic transformation (Aitchison, 1982) . However, modeling q(π|x) locally for every input is not practical, as the design efforts and number of parameters grows linearly with the number of data points. Therefore, we propose to approximate p x in two aspects: 1) use a single family of distribution q; 2) to generalize to unseen examples, let the parameter of q, α x = α(x; φ), be a function depending on x and parameterized by a set of global adaptive parameters φ, and thus q x = q(π|x) = q(π|α x ). The computational cost is amortized by casting the problem of learning a series of conditional distributions to a regression problem.

We term p x as "teacher distribution" and q x as "student". In our method, as seen in graphical representation in Fig. 3 , Appendix, by proper approximation, the stochasticity and knowledge in node θ of the teacher is transferred into node π of the student model, such that the full predictive uncertainty is maintained. In terms of computation, the approximation requires sampling only in the training stage. While in the testing stage, to obtain the predictive distribution, only one evaluation is required. Thus, we denote the framework as the One-Pass Uncertainty (OPU) model.

The above benefits do not introduce any concession on generalizability. Since OPU is based on approximating the distribution of the output class probabilities which is common for all classifiers, the amortized approximation can be applied to any Bayesian classifier. Note that the approximation framework can be extended to non-parametric model like Gaussian process, where the computational cost of inference is high1 .

In this work, we choose the student model q to be a Dirichlet distribution, q(π|α x ) = Dir(π|α x ), where α x is a function mapping input x to a Dirichlet parameter. The reasons for choosing Dirichlet is the tractability: the Dirichlet is the conjugate prior to the Categorical, and thus enables tractable integration of (2) given the parameters. To better disentangle the uncertainty measures, we use the design α x = h x • e gx , where h x = h(x; φ 1 ) and g x = g(x; φ 2 ) are two neural networks, and the vector output h sums to 1. Vector output h determines the mean of the Dirichlet (i.e., the predicted class probabilities), and g determines the concentration of the Dirichlet (i.e., the prediction confidence). To see this, the posterior of the class labels is the Dirichlet mean, p(y = 1|x, φ) = Cat(y = 1|π)Dir(π|α x ) dπ = α x, c αx,c = h x, where y and α x, are the -th coordinate of y and α x respectively. Therefore, we call h x as the "prediction model" (PM). Similarly, the precision parameter α 0 (determines sharpness) of the Dirichlet solely depends on g x , α 0 = c α x,c = c h x,c e gx = e gx . Therefore, we term g x as the "concentration model" (CM). Based on this property, whether the Dirichlet is flat or not, can be fully characterized by CM. It can be expected that, when approximating particles in Fig. 2 (a) and (b), the output value of CM is high, as the samples are concentrated, which means high confidence. CM outputs a low value for particles in Fig. 2(c ), yielding a flat distribution and low confidence.

2.3. LEARNING:

With a probability distance or divergence, we define the approximation loss L(x, α) = ρ(p x , q x ) The student model is trained to minimize the aggregated objective

EQUATION

where F is some hypothesis space and p(x) is some distribution over X . In practice we take p(x) = p D (x) with D = {x m } M m=1 a dataset containing features only. As the amortized approximation of induced distributions in Bayesian classifiers is unexplored in the literature, we consider and compare several choices of ρ including KL divergence, earth mover's distance (EMD) and maximum mean discrepancy (MMD). The corresponding derivation of the training objectives and training algorithms are in the appendix.

Forward KL divergence Minimizing aggregated reverse KL divergence is not tractable in our scenario as the density function p x is not available in general. This difficulty is avoided by using forward KL, in which the intractable density function is only involved in the irrelevant entropy term. It is equivalent to using cross-entropy as a local loss, i.e. L(x, α) = -E px ln q x . By plugging in a particle estimation px = 1 S S s=1 δ(π -T x (θ s )), the training objective becomes min α -E p D (x) 1 S s ln q x (T x (θ s )), which is equivalent to an "amortized" MLE problem with particles providing the estimation of sufficient statistics of q x . Due to the zero-avoiding nature, forward KL tends to over-estimate the support of p x . This leads to under-confidence approximation ("flat" approximate distribution) and hence might deteriorate the quality of uncertainty measurements. This is expected to be more serious when p x is multi-modal.

EMD It is known that EMD provides much weaker topology than other probability distance measures Peyré et al. (2019) . In the application where data is supported on strictly lower-dimensional manifolds, EMD provides more stable gradient than KL divergence (Arjovsky et al., 2017; Tolstikhin et al., 2017) . An example of particles on low-dimensional manifold is shown in Fig. 2(d) .

Specifically, the KR dual representation of EMD (Villani, 2008) in our problem is given by W

1 (p x , q x ) = sup ψ L ≤1 E θ∼p(θ|D) [ψ(T x (θ))] -E π∼qx [ψ(π)]

, where • L denotes the Lipschitz semi-norm and ψ is known as the critic (or the discriminator (Arjovsky et al., 2017) ). As the induced distribution is conditioned on x, a local critic ψ x should be defined for each x. Following Arjovsky et al. (2017) , intractable supremum is solved by parameterizing ψ x = ψ(•; w x ). To avoid training |D | local critics, we propose to let w be the global weight, and let ψ depends on x, i.e., ψ x = ψ(π; w, x) (see Fig. 4 , Appendix). The final aggregated training objective becomes, min

EQUATION

)

where w is the introduced global parameter for ψ, R(w) is the imposed gradient penalty (Gulrajani et al., 2017) over w to enforce the Lipschitz constraint. Solving the minimax problem requires the supremum to be attained for each x under the Lipschitz constraint. Specifically, in every optimization step, ψ is trained to generate a critic for each x that matches the exact EMD. Practically, this needs a high-capacity critic and the required capacity increases with the number of classes K.

MMD Let H k be a reproducing kernel Hilbert space (RKHS) defined by a positive-definite kernel k, the MMD between p x and q x can be written as

EQUATION

Compared with EMD, the advantage of MMD is that there is no need to train an NN as the critic that maximizes Eq. 5. With kernel trick, MMD can be readily estimated in closed-form with its empirical version under finite sample (Sec. C).

Compared with KL divergence, MMD is a valid statistical metric. Due to the symmetry property, the approximation is expected to be neither mean-seeking nor mode-seeking. Therefore, MMD is not expected to have an under-confidence issue.

Reparameterization Note that optimization under both EMD and MMD requires gradient of the expectation of critic via sampling from q, which contains parameters. To obtain efficient gradient estimator and reduce variance, we use the reparameterization trick (specifically, implicit reparameterization trick). For details, see Sec. C in Appendix.

2.4. AMORTIZATION GAP:

To better understand nature of the proposed approximation, we consider the "unamortized" version of the approximation as an intermediate stage, which involves fitting separate approximations to each p x . To demonstrate the idea, we leverage to MMD due to its nice property. For fixed p x , the optimal point-wise approximation within family Q is defined as

EQUATION

Then we have the following lemma:

Lemma 1. Let P(S K-1 ) be the space of probability measures over the simplex, equipped with MMD metric defined by a universal kernel. If T satisfies Assumption 1, then the map x → p x is continuous. Further, if Q ⊆ P(S K-1 ) is a closed convex model space, the projection q *

x is unique and the map x → q *

x is also continuous. Further, if we assume the model space is parameterized and identifiable in MMD, i.e. Q = {q(π|α) : α ∈ A} and MMD k (q(π|α), q(π|α )) = 0 if and only if αα = 0, we may obtain continuity in parameter space. The continuity of optimal parameters implies there exists a continuous function α * : x ∈ X → α * (x) ∈ A, which serves as the essential target of our amortized goal.

To analyze how amortization affects the approximation, we define the local amortization gap as

EQUATION

Then it holds that

EQUATION

where the lower bound is because q * x is the projection and the upper bound is due to triangle inequality. Then our goal, minimizing aggregated MMD loss E p(x) MMD k (q x , p x ), is essentially equivalent to minimizing aggregated amortization gap E p(x) ∆(x), up to an irrelevant additive constant. One can see that α * is the global minimizer of aggregated amortization gap and hence the global minimizer of the aggregated MMD loss. Intuitively, if F is of enough capacity, then the infimum (over F) of aggregated amortization gap could be 0, i.e. we can push the amortization gap arbitrarily small. If the optimal solution is covered by hypothesis space, no additional cost is introduced by amortizing the approximation. In other words, model loss due to using restrictive Q will dominate. Further, if the global optimum is reached, OPU approximation exactly matches the point-wise minimizer, i.e. MMD k (q x , q *

x ) = 0, due to uniqueness of projection.

3. RELATED WORK:

In this section, related works are reviewed and compared with OPU in terms of methodology. In CompactApprox (Snelson & Ghahramani, 2005) , a parametric model composed of a small subset of "best samples" selected from the original MC samples is used to approximate the full predictive Categorical distribution. Extending the approximation to Bayes NN, BDK (Balan et al., 2015) proposes to use NN to approximate the predictive Categorical distribution of a Bayes NN trained by stochastic gradient Langevin dynamics (SGLD). Specifically, the teacher network generates samples via SGLD and KL between the two distributions is minimized in an online fashion. However, the disadvantage is that data uncertainty, model uncertainty and distributional uncertainty are all entangled in the class probabilities because categorical distributions are of limited expressiveness.

Different from these previous works that only approximate the class probabilities, OPU approximates the induced distribution of class probabilities, which contains richer information including both class probabilities and prediction confidence (e.g., the three types of uncertainty observable via the samples in Fig. 2 .) We choose a Dirichlet distribution as the student model, and explicitly disentangle the mean and concentration to fully capture the thee types of uncertainty. We also explore other probability distance measures (EMD and MMD), showing that KL yields degenerate prediction performance.

Using a Dirichlet to estimate uncertainty has also been explored by Deep Prior Network (DPN) (Malinin & Gales, 2018) 

4. EXPERIMENTS:

4.1 EXPERIMENTAL SETUP Models and Tasks In this section, we present the experimental results on using Bayesian NN (BNN). 2 For each model, we choose a few Bayesian methods as teachers, and approximate them with our OPU. We also compare with state-of-the-art approximations that are proposed for the specific types of methods. For BNN, we use MCDP (Gal & Ghahramani, 2016) and SGLD (Welling & Teh, 2011) as the teacher, and BDK and DPN for comparisons. The methods for obtaining posterior samples from the Bayes teachers are in Appendix B. For each type of model, in-domain misclassification (MisC) detection, out-of-domain (OOD) input detection, prediction performance and prediction time are presented.

Baselines and Uncertainty Measures For the uncertainty measures of teachers, we take MCDP and KL as a example. For each testing data x, a Dirichlet is fit on particles under KL, to get an optimal q * x , whose differential entropy (D) is an uncertainty measure. For the uncertainty in prediction, to avoid the model loss, entropy (E) and maximum probability (P) of the averaged particle are directly adopted as uncertainty measures. This gives MCDP-KL model as a baseline. The other baselines MCDP-EMD and MCDP-MMD are also obtained similarly. Note that they share the same E and P as the sample mean is the same. The D of q *

x is expected to be the best uncertainty measure that OPU can approach theoretically (when the amortization loss is zero, see Sec. 2.4). For fairness, the same set of posterior particles is used for obtaining D. The baselines for SGLD are obtained in a similar way. Students use categorical entropy (for BDK) or D (for DPN) and P of the output distributions. For OPU, we consider E and P of the prediction model, and the scalar output of the concentration model (C) as the measures. OPU vs BDK. In some tasks especially OOD detection, the measure of concentration outperforms the baseline. This is because the explicit disentanglement of mean and concentration helps "targeted" knowledge distillation, as shown in Sec. 2.2. By comparing OPU-SGLD-KL and BDK (trained by forward KL), we observe that OPU-SGLD-KL is significantly better in OOD detection tasks and AUROC in MisC detection. BDK shows a slight advantage in AUPR in MisC detection task. This is because the knowledge distillation only happens between two categorical variables in BDK, which only helps capturing prediction information. In contrast, OPU framework first extracts all information in a BNN with the induced distribution, then transfers the knowledge to a more expressive distribution with a small loss guaranteed (Sec. 2.4). Adding a Dirichlet distribution to BDK (BDK-DIR-SGLD) helps improving the performance in OOD detection. However, on SEMEION, which is expected to be harder as it is more similar to MNIST, there is a large performance difference from OPU. ) . This is because the samples of MCDP are relatively spread out over the simplex and might be multi-modal. The probability distance is fully captured by MMD under such case. EMD is expected to perform well as there are a lot of samples π s residing on a low-dimensional manifold. However, the performance seems to be degenerated due to the limited capacity of the hyper-network and the difficulty to train the minimax problem. KL presents the worst performance as expected because it is likely to be under confident with samples of MCDP. With SGLD, the performance of KL is the best except for AUROC of MisC detection. This is because the samples π s of SGLD over the simplex are much denser and are typically unimodal.

Data and Evaluation Metrics:



KL vs MMD (EMNIST).:

The experiments are conducted on EMNIST whose number of classes is large. We choose Omniglot as the OOD detection dataset as it is also contains handwritten characters, which are harder than SEMEION for a model trained on EMNIST. A CNN with structure similar with LeNet is used for MCDP and OPU (20 and 50 output channels in two convolutional layers). The baseline approach achieves a classification accuracy of 88.8%. The samples of MCDP Bayes NN are expected to be even more dispersive and multi-modal than MCDP trained with MNIST. OPU trained with EMD failed to converge, possibly because the capacity of the hypernetwork was not enough. Therefore, we do not recommend to use EMD for amortized approximation of predictive uncertainty, unless a more scalable estimator of EMD can be provided. As shown in Table 2 , the performance gap between OPU-MCDP-KL and the baseline is larger because the multi-modality is severe -the entropy of sample mean is a better measure for OOD detection than the concentration. This further validates that OPU trained by KL suffers from an under-confidence issue. Specifically, KL forces OPU to cover the support of all samples, making the student distribution more dispersive. This inaccurate estimate of concentration affects the estimation of prediction results (mean) in turn, thus the accuracy is lower and MisC detection performance is degenerated. By contrast, MMD consistently provides an approximation that has similar performance with the teacher, that echoes the analysis in Sec. 2.4. Amortization Gap. The details of experiments on the approximation error/gap can be found in appendix D.3. It is shown that the amortization gap of using OPU is small, indicating the function space is enough to cover the essential target. It also shows the approximation error is mainly from the model error of using Dirichlet distribution, which is small as well, see appendix D.3 for details.

5. DISCUSSION:

The idea of "transferring" the randomness from model posterior to a simple-structure distribution at the output can be generalized to other problems where a real-time evaluation of uncertainty is critical, e.g., object segmentation. This allows interesting designs of structured output distributions.

The choice of student distribution for OPU is flexible. Although we verify that Dirichlet is suitable for the tested classification tasks, there are still chances that Dirichlet incurs great model error. Note that, in our framework, using a Dirichlet for the student is modeling choice, similar to assuming Gaussian posteriors for variational approximations. The OPU framework is general and any student distribution can be adopted, e.g., generalized Dirichlet, mixture of Dirichlets. To do this requires: 1) a suitable parametrization of the model that can capture uncertainty; 2) deriving/computing the approximation loss (KL, MMD, EMD); 3) reparameterization trick of expectations for efficient gradient estimation. The algorithms of KL, EMD and MMD as well as the analysis still apply. A APPENDIX: PROOF Assumption 1. Let T : X × Θ → Y be a map between finite dimensional vector spaces. We say T satisfies Assumption 1 for distribution p if T (•; θ) is Lipschitz and the Lipschitz constant L θ satisfies E θ∼p L θ < +∞.

Proof. We simply show both maps are Lipschitz continuous with MMD metric on P(S K-1 ). Let x, x ∈ X and ψ ∈ H k such that ψ H k ≤ 1. For x → p x , the "push-forward" definition of p x leads to

MMD k (p x , p x ) = sup ψ ≤1 E p(θ|D) ψ(T x (θ)) -E p(θ|D) ψ(T x (θ)) ≤ sup ψ ≤1 E p(θ|D) |ψ(T x (θ)) -ψ(T x (θ))| ≤ sup ψ ≤1 ψ E p(θ|D) d k (T x (θ), T x (θ)) ≤ CE p(θ|D) T x (θ) -T x (θ) ≤ CE p(θ|D) L θ x -x ,

where d k = is a kernel-based distance. The constant C emits when bounding d k with Euclidean norm and the existence of such a constant is due to topology equivalence in finite-dimensional space. For x → q * x , we notice that q * x is the projection of p x onto Q (effectively the projection of kernel mean embeddings in H k ). By projection theorem in Hilbert space, the projection map p x → q *

x is non-expansive, i.e.

MMD k (q * x , q * x ) ≤ MMD k (p x , p x ), which leads to Lipschitz property of x → q *

x .

B APPENDIX: PLOTS.

The graph representations of original view , isolated view of Bayes teacher and the student are shown in Fig. 3 .

C APPENDIX: ALGORITHMS.

For presenting the algorithms, we slightly change the notation. We let α(x) = α(x, φ), h(x) = h(x, φ 1 ), g(x) = g(x, φ 2 ), where φ = {φ 1 , φ 2 }, φ 1 and φ 2 are the parameters of prediction model h and concentration model g, respectively.

KL. With the training objective The student model is updated by doing φ t+1

EQUATION

! "|$ % ! "|$ & ! % ' ( & ) % ) ) (a) (b) (c)

1 := φ t 1 -γ t (-1 S θs ∇ φ1 ln q(T (x * ; θ s )|α(x * ; φ 1 ))) and φ t+1 2 := φ t 2 -γ t (-1 S θs ∇ φ2 ln q(T (x * ; θ s )|α(x * ; φ 2 )))

alternately, where γ t is the learning rate at iteration t and x * is the input at this iteration. 

EMD. With the following training objective,:

min φ max w E p D (x) E p(θ|D) [ψ(T x (θ); w, x)] -E qx [ψ(π; w, x)] + λR(w),

. T stu do:

Sample {π s } S s =1 ∼ q(π|x (i) , φ)

L (i) (φ 1 ) = - S s =1 ψ(π s ; w, x (i) ) φ 1 ← Adam(∇ φ1 L (i) ) Sample {π s } S s =1 ∼ q(π|x (i) , φ) L (i) (φ 2 ) = - S s =1 ψ(π s ; w, x (i) ) φ 2 ← Adam(∇ φ2 L (i) ) end / * Update Critic * / for iter in 1 . . . T wit do Sample {π S s =1 } ∼ q(π|x (i) , φ) Compute R(v) L (i) (v) = S s=1 ψ(T (x; θ s ); w, x (i) ) - S s =1 ψ(π s ; w, x (i) ) + λR(w) v ← Adam(∇ v L (i) ) end end

MMD. The kernel mean embedding of p x and q x are given by µ

EQUATION

Critic (•; w, x)

< l a t e x i t s h a 1 _ b a s e 6 4 = " F + P

V s 9 T s V X l f 6 N Z s N u 2 v z u E L I f o = " > A A A C A 3 i c b V D L S s N A F J 3 U V 6 2 v q D v d D B a h g p S k C g p u i m 5 c V r A P a E K Z T C b t 0 E k m z E z U E g p u / B U 3 L h R x 6 0 + 4 8 2 + c t F l o 6 4 E L h 3 P u 5 d 5 7 v J h R q S z r 2 y g s L C 4 t r x R X S 2 v r G 5 t b 5 v Z O S / J E Y N L E n H H R 8 Z A k j E a k q a h i p B M L g k K P k b Y 3 v M r 8 9 h 0 R k v L o V o 1 i 4 o a o H 9 G A Y q S 0 1 D P 3 n F j S i o N 9 r i 7 g / T F 0 Q q Q G X p A + j I 9 6 Z t m q W h P A e W L n p A x y N H r m l + N z n I Q k U p g h K b u 2 F S s 3 R U J R z M i 4 5 C S S x A g P U Z 9 0 N Y 1 Q S K S b T n 4 Y w 0 O t + D D g Q l e k 4 E T 9 P Z G i U M p R 6 O n O 7 E Q 5 6 2 X i f 1 4 3 U c G 5 m 9 I o T h S J 8 H R R k D C o O M w C g T 4 V B C s 2 0 g R h Q f W t E A + Q Q F j p 2 E o 6 B H v 2 5 X n S q l X t k 2 r t 5 r R c v 8 z j K I J 9 c A A q w A Z n o A 6 u Q Q M 0 A Q a P 4 B m 8 g j f j y X g x 3 o 2 P a W v B y G d 2 w R 8 Y n z / p t 5 c O < / l a t e x i t >

x < l a t e x i t s h a 1 _ b a s e 6 4 = " C P n / A H 6 z y e t D u K 2 a 

X v + D R Q K M H f 0 = " > A A A B 8 X i c b V D L S g M x F L 3 j s 9 Z X 1 a W b Y B F c l Z k q 6 L L o x m U F + 8 C 2 l E x 6 p w 3 N Z I Y k I 5 a h f + H G h S J u / R t 3 / o 2 Z d h b a e i B w O O d e c u 7 x Y 8 G 1 c d 1 v Z 2 V 1 b X 1 j s 7 B V 3 N 7 Z 3 d s v H R w 2 d Z Q o h g 0 W i U i 1 f a p R c I k N w 4 3 A d q y Q h r 7 A l j + + y f z W I y r N I 3 l v J j H 2 Q j q U P O C M G i s 9 d E N q R n 6 Q P k 3 7 p b J b c W c g y 8 T L S R l y 1 P u l r + 4 g Y k m I 0 j B B t e 5 4 b m x 6 K V W G M 4 H T Y j f R G F M 2 p k P s W C p p i L q X z h J P y a l V B i S I l H 3 S k J n 6 e y O l o d a T 0 L e T W U K 9 6 G X i f 1 4 n M c F V L + U y T g x K N v 8 o S A Q x E c n O J w O u k B k x s Y Q y x W 1 W w k Z U U W Z s S U V b g r d 4 8 j J p V i v e e a V 6 d 1 G u X e d 1 F O A Y T u A M P L i E G t x C H R r A Q M I z v M K b o 5 0 X 5 9 3 5 m I + u O P n O E f y B 8 / k D / o e R I A = = < / l a t e x i t > ⇡ < l a t e x i t s h a 1 _ b a s e 6 4 = " 6 v I x G D w h + U G q I r + y 0 2 C + U h L 2 K J Y = " > A A A B + X i c b V D L S s N A F L 2 p r 1 p f U Z d u B o v g q i R V 0 G X R j c s K 9 g F N K J P J p B 0 6 m Y S Z S a G E / o k b F 4 q 4 9 U / c + T d O 2 i y 0 9 c A w h 3 P u Z c 6 c I O V M a c f 5 t i o b m 1 v b O 9 X d 2 t 7 + w e G R f X z S V U k m C e 2 Q h C e y H 2 B F O R O 0 o 5 n m t J 9 K i u O A 0 1 4 w u S / 8 3 p R K x R L x p G c p 9 W M 8 E i x i B G s j D W 3 b C x I e q l l s r t x L 2 X x o 1 5 2 G s w B a J 2 5 J 6 l C i P b S / v D A h W U y F J h w r N X C d V P s 5 l p o R T u c 1 L 1 M 0 x W S C R 3 R g q M A x V X 6 + S D 5 H F 0 Y J U Z R I c 4 R G C / X 3 R o 5 j V Y Q z k z H W Y 7 X q F e J / 3 i D T 0 a 2 f M 5 F m m g q y f C j K O N I J K m p A I Z O U a D 4 z B B P J T F Z E x l h i o k 1 Z N V O C u / r l d d J t N t y r R v P x u t 6 6 K + u o w h m c w y W 4 c A M t e I A 2 d I D A F J 7 h F d 6 s 3 H q x 3 q 2 P 5 W j F K n d O 4 Q + s z x 9 A / 5 Q P < / l a t e x i t > NN1 NN2 Feat Feat Concatenate NN3 Scalar Estimate of EMD w < l a t e x i t s h a 1 _ b a s e 6 4 = " K + i i v r h d e U P n W o x m B 5 C J Q N d K l 6 I = " > A A A B 6 H i c b V D L T g J B E O z F F + I L 9 e h l I j H x R H b R R I 9 E L x 4 h k U c C G z I 7 9 M L I 7 O x m Z l Z D C F / g x Y P G e P W T v P k 3 D r A H B S v p p F L V n e 6 u I B F c G 9 f 9 d n J r 6 x u b W / n t w s 7 u 3 v 5 B 8 f C o q e N U M W y w W M S q H V C N g k t s G G 4 E t h O F N A o E t o L R 7 c x v P a L S P J b 3 Z p y g H 9 G B 5 C F n 1 F i p / t Q r l t y y O w d Z J V 5 G S p C h 1 i t + d f s x S y O U h g m q d c d z E + N P q D K c C Z w W u q n G h L I R H W D H U k k j 1 P 5 k f u i U n F m l T 8 J Y 2 Z K G z N X f E x M a a T 2 O A t s Z U T P U y 9 5 M / M / r p C a 8 9 i d c J q l B y R a L w l Q Q E 5 P Z 1 6 T P F T I j x p Z Q p r i 9 l b A h V Z Q Z m 0 3 B h u A t v 7 x K m p W y d 1 G u 1 C 9 L 1 Z

M S q H V C N g k t s G G 4 E t h O F N A o E t o L R 7 c x v P a L S P J b 3 Z p y g H 9 G B 5 C F n 1 F i p / t Q r l t y y O w d Z J V 5 G S p C h 1 i t + d f s x S y O U h g m q d c d z E + N P q D K c C Z w W u q n G h L I R H W D H U k k j 1 P 5 k f u i U n F m l T 8 J Y 2 Z K G z N X f E x M a a T 2 O A t s Z U T P U y 9 5 M / M / r p C a 8 9 i d c J q l B y R a L w l Q Q E 5 P Z 1 6 T P F T I j x p Z Q p r i 9 l b A h V Z Q Z m 0 3 B h u A t v 7 x K m p W y d 1 G u 1 C 9 L 1 Z

(i) ∼ p D (x) Sample {π q,s } S s =1 ∼ q(π|x (i) , φ), get {π p,s } S s =1 = {T (x|θ s )} S s =1 L (i) (φ 1 ) = 1 S (S -1) S m =n k(π q,m , π q,m ) + 1 S (S -1) S m =n k(π p,m , π p,m ) - 2 S (S -1) S ,S m,n=1 k(π q,m , π p,n ) φ 1 ← Adam(∇ φ1 L (i) ) Sample {π s } S s =1 ∼ q(π|x (i) , φ) L (i) (φ 1 ) = 1 S (S -1) S m =n k(π q,m , π q,m ) + 1 S (S -1) S m =n k(π p,m , π p,m ) - 2 S (S -1) S ,S m,n=1 k(π q,m , π p,n ) φ ← Adam(∇ φ2 L (i)

) end Reparameterization: To obtain efficient gradient estimator and reduce variance, we reparameterize the Dirichlet by an equivalent product of K independent Gamma distributions. If π ∼ PG( π|α) = K k=1 Gam(π k |α k ), then π = ( k πk )

-1 π ∼ Dir(π|α). By Thm. 3 in (Arjovsky et al., 2017) , in each L(φ|x), the supremum is attained at ψ * x ∈ L 1 and the gradient is

∇ φ L(φ|x) = -∇ φ E q(π|x,φ) [ψ * x (π)].

Then as noted by (Figurnov et al., 2018) , the gradient ∇ φ L(φ|x) can be implicitly computed without knowing the inverse of standardization function (e.g., CDF). Specifically, by Eq. 5 in (Figurnov et al., 2018) 

, ∇ φ E q(π|x;φ) [ψ * x (π)] = E PG( π|x;φ) [∇ π ψ * x (π)∇ φ π],

where the first term ∇ π ψ *

x (π) is computed via the chain rule and the second term ∇ φ π is obtained by solving a local diagonal linear system. Refer to (Figurnov et al., 2018) and references therein for details.

D APPENDIX: EXPERIMENTS:

For the critic in EMD used in MNIST experiments, NN1 is a 784-256 MLP, NN2 is a 10-256 MLP and NN3 is a 512-256-1 MLP (see Fig. 4 ). For the critic in EMD used in MNIST experiments, NN1 is the same as convolutional layers used in Ba, NN2 is a 10-256 MLP and NN3 is a 512-256-1 MLP (see Fig. 4 ).

D.1 BAYESIAN LOGISTIC REGRESSION:

We test two models in this experiment: Polya Gamma (PG), CompactApprox approximating PG (CA-PG) and OPU approximating PG (OPU-PG). We draw 500 posterior samples from PG and train OPU with the following hyperparameters: number of epochs 100, learning rate for student. CA-PG is trained by first drawing 5000 samples from PG then evaluating the model with 50 randomly selected samples from them (same setup as CompactApprox). The random selection is repeated for 10 5 times and we pick the best group of samples. As the results for the three metrics are similar, we only show the results trained with KL divergence.

The results are shown in Table 3 . OPU-PG maintains similar performance with the original PG on prediction accuracy and MisC detection. Meanwhile, OPU outperforms CA-PG on prediction accuracy, MisC and OOD detection. For OPU, CM outperforms other uncertainty measures at OOD detection, which indicates it captures the distributional uncertainty well. OPU performs better than the PG Bayes teacher. The reason might be that a parametric model is learned to approximate the ensemble of discrete samples, which could produce a smoother output distribution (regularization), leading to better performance. OPU also achieves a ∼100-600x speedup from the original PG.

D.2 GAUSSIAN PROCESS:

For GP, we use SGPMC (Hensman et al., 2015a) as the teacher, and SVGP (Hensman et al., 2015b) for comparison.

This experiment uses Pima and Spambase datasets as D in . Pima is a medical dataset with 769 data points and 9 dimensions. Spambase is a text dataset with 4601 data points and 57 dimensions for identifying spam email. We generate the same number of data points from a zero-mean multivariate Gaussian distribution for D ood . For each dataset, 10% of data points are uniformly selected into the testing set D te . We normalize the data by features with L2 norm. where K is the number of classes. There are 3 models tested: SGPMC, OPU approximating SGPMC (OPU-SGPMC) and SVGP. SGPMC and SVGP are trained with 1 10 |D in | data points randomly selected from D in as inducing points. Then 500 samples over functions of D in are generated from SGPMC. As the results for the three metrics are similar, we only show the results trained with KL divergence.

The results are presented in Table 4 . On MisC detection and prediction accuracy, OPU has similar performance to SGPMC, which indicates the effectiveness of approximating prediction results with ensemble of samples in the nonparametric family. With the same number of inducing points, SVGP performs slightly worse than SGPMC, because it incurs a two-fold approximation. Measuring uncertainty with CM in OPU outperforms other measures and models, which indicates the sharpness of the logistic-normal distribution can be captured via the CM the designed Dirichlet. SGPMC and SVGP are faster than OPU on Pima, but are slower than OPU on the larger Spambase. This is due to the static latency for setting up the GPU for OPU, which becomes the main time cost when the dataset is small (as in Pima). For the two GP methods, the computation time depends on the number of inducing points and the number of dimensions. Therefore, as the dataset becomes larger (Spambase), the computation time increases. Computation of AUROC/AUPR: First, we show how AUROC/AUPR is calculated. We use entropy (E) and max probability (P) of the particle mean, and differential entropy (D) of locally fitted student distribution as the measures for the teacher. We use entropy (E) and max probability (P) of the particle mean, and the scalar output of student concentration model (C) as the measures for the OPU student.

For OOD detection, say q x1 has higher E (or lower P or lower C) than q x2 , then q x1 is more likely to be an OOD data. The value of E, P and C (D for the teacher) are computed for all testing data points (both in domain data and out-of-domain data), which rank the data points based on the numerical magnitude. The ROC curve is plotted by setting threshold on each magnitude and compute the True Positive Rate and False Positive Rate at each threshold. The PR curve is plotted similar by computing the Precision and Recall. Then the area under two curves (AUROC and AUPR) can be obtained. For misclassification detection, the similar calculation process is applied.

Error/gap: Second, we use the four types of error/gap under MMD defined in Sec. 2.4 to show the effectiveness of amortized approximation and the suitableness of using Dirichlet family. Specifically, the following measures are used:

• Averaged total approximation error (Avg.Approx.Err.): The averaged MMD between teacher's particles (for each x) and the predicted Dirichlet by OPU, i.e., and Avg.Model.Err., i.e., ∆(x), defined in Eq. 7.

• Averaged local amortization error (Avg.Amt.Err.): We define this type of error to be the averaged MMD between locally fitted Dirichlet (for each x) and the predicted Dirichlet by OPU, i.e., 1 N N i=1 MMD(q xi , q * xi ). The relation between Avg.Amt.Gap and Avg.Amt.Err. is given by Eq. 8.

We show the numerical results on EMNIST dataset by Table 5 . It can be observed that the Avg.Amt.Err. 0.0053 is low and it bounds the Avg.Amt.Gap ∆(x)=Avg.Approx.Err. -Avg.Model.Err=0.0049, which is consistent with Eq. 8. The approximation error is mainly determined by the model error, which turns out to be acceptably small. This is consistent with the analysis and also shows the effectiveness and suitableness of using Dirichlet family.

Cifar10 results: Third, we show the experimental results of OPU approximating Bayesian NN on Cifar10 dataset in Table 6 . The NN model for teacher and student is standard VGG19 with the output dimension of concentration model to be 1. The MCDP teacher model is trained with SGD optimizer and a cyclical learning rate policy. The base learning rate is initialized to be 0.01 and linearly increased to 10x of learning rate, then decreases back to the base learning rate. The base learning rate is then scaled by half. The number of MCDP particles is 700. The OPU students are trained with KL/EMD/MMD using the corresponding algorithm for 200 epochs.

As the task is harder than MNIST, particles tends to be more spread over the corners. Under such case, it can be observed that the performance of EMD and MMD is much better than that of KL.

Teachers with fewer samples: Fourth, the performance of original MCDP/SGLD with fewer samples is shown in Table 7 . We note that using few particles would affect the performance of Bayesian classifier, especially the performance on OOD detection. In real-world cases like automatic driving car where the robustness is critical, it is not worth to trade safety for speed. Therefore, OPU solves this issue by providing accurate estimation of predictive uncertainty with short evaluation time. Besides the speedup, OPU approximation provides a full distribution to characterize the predictive 98.5 (-0.9) 82.7 (-4.1) 94.9 (-3.0) 132.1 SGLD 97.1 (-0.9) 91.2 (-8.0) 82.5 (-6.8) 98.0 (-0.4) 141.9 distribution, which is not available with particle approximation. This allows for better uncertainty measures such as differential entropy.

Un-distilled teachers: Finally, we show the detailed un-distilled MCDP/SGLD, whose elements might be covered by differential entropy of locally fitted Dirichlet in Table 1 . The detailed results are shown in Table 8 E APPENDIX: SAMPLING

In this section, we illustrate the details for extracting samples from Bayesian logistic regression, Bayesian neural network and Gaussian process. Under some contexts, we use X and Y to collectively denote the inputs and outputs respectively for previous D.

E.1 BAYESIAN LOGISTIC REGRESSION:

The Polya-Gamma (PG) scheme (Polson et al., 2013) is a data augmentation strategy that allows for a closed-form Gibbs sampler. In binary classification, i.e., y n ∈ Y = {1, 0}, let θ be the regression coefficients with a Gaussian conditional conjugate prior p(θ) ∼ N (0, Λ -1 ). The PG Gibbs sampler is composed of the following two conditionals,

EQUATION

where ω n is the augmenting data corresponding to the nth data point. The posterior conditional variance and mean are given by V ω = (X T ΩX+Λ -1 ) -1 and m ω = V -1 ω (X T (y-1 2 )), respectively. Given this formulation we will be able to collect samples from the posterior after a burn-in period. The posterior samples {θ} S s=1 , together with dataset D , are used to train our approximation with goal defined in Eq. 10.

As an MCMC method, the PG augmentation scheme offers accurate samples. Other alternative methods such as local variational approximation can be employed, which are much faster but sacrifice accuracy.

E.2 MONTE CARLO DROPOUT:

A neural network with dropout applied before every weight layer was shown to be an approximation to probabilistic deep Gaussian process (GP) (Gal & Ghahramani, 2016) . Let q(θ) to be the approximate distribution to the GP posterior. Here, θ = {Θ i } L i=1 and Θ i is a parameter matrix of dimensions K i × K i=1 for NN layer i. In this approximation, q(θ) can be defined through direct modification: where z i,j ∼ Bern(p i ) for i ∈ [L] and j ∈ [K i-1 ], given some prior dropout probabilities p i and matrices Θ i are treated as variational parameters. The binary variable z i,j = 0 indicates that unit j in layer i -1 being dropped out as an input to layer i. The predictive mean of this approximation is given by E[y|x] ≈ 1 S S s=1 f (x, ẑ1,s , . . . , ẑL,s ), which hence referred to as MC dropout (MCDP). We use OPU to approximate the uncertainty induced by q(θ). A sample in the MC ensemble is given by θ s = {Θ i,s } L i=1 = M i diag([z i,j ] Ki i=1 ). We set φ 1 = {Φ i } L i=1 Z to the mean of θ s , i.e.,

EQUATION

Φ i = 1 S S s=1 Θ i,s = M i 1 S S s=1 diag([z i,j,s ] Ki i=1

). MCDP provides a simple way of approximating Bayesian inference through dropout sampling. However, it still introduces a variational approximation to exact Bayesian posterior. Therefore, we further include a more accurate way to generate MC ensemble -stochastic gradient Langevin dynamics (SGLD).

E.3 VANILLA SGLD:

SGLD enables mini-batch MC sampling from the posterior via adding a noise step to SGD (Welling & Teh, 2011) . We choose the "vanilla" version of SGLD in our approximation. Specifically, we start training of f θ (•) from θ (0) . In each epoch with mini-batch size B,

EQUATION

= θ (t) + t ∇(log p(θ (t) ) + 

where B is the size of a mini-batch and η t ∼ N (0, 2 t I). After SGLD converges at step T , the samples θ s = θ (T +s) is collected by running the training process for another S iterations. We use averaged samples as parameter of h, i.e., φ 1 = 1 S S s=1 θ s and train OPU by Eq. 10 with this ensemble.

E.4 MONTE CARLO GAUSSIAN PROCESS:

We apply the OPU framework to the GP framework, which demonstrate its use on a non-parametric classifier. Let data D be split into as input matrix X and output matrix Y. We consider GP prior over the space of functions, i.e., µ ∼ GP(0, K). where K is a positive definite kernel controlling the prior belief on smoothness. Existing techniques allow us to compute q(µ) which approximates p(µ|D) and is comparable to previous q(θ) under a parametric model. In a classification task, the posterior p(µ|D) can be sampled via MCMC (Hensman et al., 2015a) or approximated, e.g., via variational approximation (Hensman et al., 2015b) . Let µ * be a shorthand for µ x and π is then defined as S(µ * ). If Gaussian variational approximation is used, the marginal posterior p(µ * |x, D) at x induces a logistic-normal distribution for p(π|x, D). In our approximation, we obtain samples {µ * s } S s=1 from p(µ * |x, D). The optimization goal is the same as that in the NN case with a different target distribution defined as p(π|x, D) = 1 S S s=1 δ(π -S(µ * s )).

(16)

:

The details of extracting samples from various Bayes parametric models and non-parametric model (GP classifier) are summarized in the appendix.

The setup and results on BLR and GP are available in the appendix.

Figures and Tables:

5 H c 9 Z q 5 w j 8 g P X 2 C d 1 i l P w = < / l a t e x i t > ⇡ 2 < l a t e x i t s h a 1 _ b a s e 6 4 = " a y e v E E z Z 9 b i e l 8 F c Y o I m l n m A 8

A 3 a o A M I u A c P 4 A k 8 G 3 P j 0 X g x X p e j B W O 1 c w R + w H j 7 B N 7 m l P 0 = < / l a t e x i t > … ⇡ S < l a t e x i t s h a 1 _ b a s e 6 4 = " 2 7 f s T i R n I w j e d w e U j Z 2 J o 7 x s g n A = " > A A A B + 3 i c d V B L S w M x G M z 6 r P V V 6 9 F L s A i e S r b V P m 5 F L x 4 r 2 g d 0 l 5 L N Z t v Q b H Z J s m J Z + l e 8 e F D E q 3 / E m / / G b F t B R Q d C h p n v I 5 P x Y s 6 U R u j D W l l d W 9 / Y z G 3 l t 3 d 2 9 / Y L B 8 W u i h J J a I d E P J J 9 D y v K m a A d z T S n / V h S H H q c 9 r z J Z e b 3 7 q

e H d 8 S O S h F R o w r F S A x v F 2 k 2 x 1 I x w O s s 7 i a I x J h M 8 o g N D B Q 6 p c t N 5 9 h k 8 M Y o P g 0 i a I z S c q 9 8 3 U h y q L J 6 Z D L E e q 9 9 e J v 7 lD R I d N N y U i T j R V J D F Q 0 H C o Y 5 g V g T 0 m a R E 8 6 k h m E h m s k I y x h I T b e r K m x K + f g r / J 9 1 K 2 a 6 W K 9 d n p d b F s o 4 c O A L H 4 B T Y o A 5 a 4 A q 0 Q Q c Q c A 8 e w B N 4 t m b W o / V i v S 5 G V 6 z l z i H 4 A e v t E x D 5 l R 4 = < / l a t e x i t > … ✓ 1 < l a t e x i t s h a 1 _ b a s e 6 4 = " 8 3 W M N 5 d J m 7 G z m r r n h c g L x d g / r e E = " > A A A B / n i c d V D L S g M x F M 3 U V 6 2 v q r h y E y y C q y H T a h + 7 o h u X F e w D 2 l I y m b Q N z T x I 7 g h l K P g r b l w o 4 t b v c O f f m G k r q O i B k M M 5 9 5 K T 4 0 Z S a C D k w 8 q s r K 6 t b 2 Q 3 c 1 v b O 7 t 7 + f 2 D l g 5 j x X i T h T J U H Z d q L k X A m y B A 8 k 6 k O P V d y d v u 5 C r 1 2 3 d c a R E G t z C N e N + n o 0 A M B a N g p E H + q O e G 0 t N T 3 1 x J D 8 Y c 6 G z g D P I F Y p d r 5 e J F D R O b E F I u O Y Y 4 p F q p l L C T K g Y F t E R j k H / v e S G L f R 4 A k 1 T r r k M i 6 C d U g W C S z 3 K 9 W P O I s g k d 8 a 6 h A f W 5 7 i f z + D N 8 a h Q P D 0 N l T g B 4 r n 7 f S K i v 0 4 R m 0 q c w 1 r + 9 V P z L 6 8 Y w r P Y T E U Q x 8 I A t H h r G E k O I 0 y 6 w J x R n I K e G U K a E y Y r Z m C r K w D S W M y V 8 / R T / T 1 p F 2 y n Z x Z v z Q v 1 y W U c W H a M T d I Y c V E F 1 d I 0 a q I k Y S t A D e k L P 1 r 3 1 a L 1 Y r 4 v R j L X c O U Q / Y L 1 9 A k V D l l c = < / l a t e x i t > ✓ 2< l a t e x i t s h a 1 _ b a s e 6 4 = " 7 C X 0 q + 8 2 W T 1 M J o 5 O J + i A D T T p v K M = " > A A A B / n i c d V D L S g M x F M 3 U V 6 2 v q r h y E y y C q y H T a h + 7 o h u X F e w D 2 l I y a a Y N z T x I 7 g h l K P g r b l w o 4 t b v c O f f m G k r q O i B k M M 5 9 5 K T 4 0 Z S a C D k w 8 q s r K 6 t b 2 Q 3 c 1 v b O 7 t 7 + f 2 D l g 5 j x X i T h T J U H Z d q L k X A m y B A 8 k 6 k O P V d y d v u 5 C r 1 2 3 d c a R E G t z C N e N + n o 0 B 4 g l E w 0

o B 6 y 3 T 3 j L l n k = < / l a t e x i t > Margin. p(y|x, D) < l a t e x i t s h a 1 _ b a s e 6 4 = " 1 8 d Z b c M 2 e g x D n H B X 9 d J C / L t 8 n M k = " > A A A C E 3 i c d Z D L S g M x F I Y z 9 V b r r e r S T b A I V W S Y 6 f S 6 K + r C Z Q V 7 g b a U T J p p Q z M X k o x Y x n k H N 7 6 K G x e K u H X j z r c x v Y G K / h D 4 + M 8 5 5 J z f D h g V 0 j A + t c T S 8 s r q W n I 9 t b G 5 t b 2 T 3 t 1 r C D / k m N S x z 3 z e s p E g j H q k L q l k p B V w g l y b k a Y 9 O p / U m z e E C + p 7 1 3 I c k K 6 L B h 5 1 K E Z S W b 3 0 S W e I Z B T E 2 Y 6 L 5 N B 2 o n F 8 t 8 D b + H S K G L H o I j 7 u p T O G b l h W

t e x i t s h a 1 _ b a s e 6 4 = " M C j x f B g c e z Y I c b 7 v 0 M y 6 n I G 8 P j 0

e 0 o 6 G P P S q 7 8 f S O C T z U T B + 6 g d D P V 3 D K f p + I s S c T o 7 o z s S h / a w n 5 l 9 a J l F v p x s w P I 0 V 9 M l v k R h y q A C a h w D 4 T l C g + 1 g A T w b R X S I Z Y Y K J 0 d B k d w t e l 8 H / Q L O S t Y r 5 w c Z y t n c 7 j S I M 9 c A B y w A J l U A P n o A 4 a g I A 7 8 A C e w L N x b z w a L 8 b r r D V l z G d 2 w Y 8 y 3 j 4 B g f u a Y A = = < / l a t e x i t > t e x i t s h a 1 _ b a s e 6 4 = " d o H V v 8 / 4 J L w 3 / V e m W 2 i s s 1 r / b 9 U

y g w e I A n e L b u r E f r x X p d t h a s 1 c w x / I D 1 9 g k e 5 4 0 n < / l a t e x i t > t e x i t s h a 1 _ b a s e 6 4 = " v d z m A T c 8 T

Figure 1: An intuitive example of the proposed framework. Only one input x is consider in this example. "Margin." indicates marginalization over π.

Figure 2: An empirical example of MC estimate of the induced distribution over simplex. The classifier (MCDP) is trained on real-world digits images of {0, 1, 2} (corresponding to left, right, top corners of simplex). The 1st and 3rd rows indicate the input while the 2nd and 4th rows indicate MC estimate of π over a 2-simplex.

For a fair comparison, we let D = D in the approximation of OPU. The in-domain dataset is split to training data and testing data, i.e., D in = D = {D tr , D te }, which is used for training models, evaluating prediction and MisC detection. The OOD dataset D ood and D te are used for OOD detection. To assess the performance, we use accuracy, time, Area under the ROC

Figure 3: Graphical representation of probabilistic structure of the Bayes teacher (left and middle) and the student (right). Dashed edges denote deterministic dependence, box nodes are deterministic and circle nodes are stochastic. The left and middle graphs correspond to the LHS and RHS of (2), respectively.

OPU Training Algorithm with EMD Input: Posterior samples: {θ s } S s=1 ; OPU training data D ; Gradient penalty coefficient λ; Number of training iterations: T stu and T wit . while φ not converge do Sample x (i) ∼ p D (x) / * Update Approximation * / for iter in 1 . .

s s j j y c w C m c g w d X U I U 7 q E E D G C A 8 w y u 8 O Q / O i / P u f C x a c 0 4 2 c w x / 4 H z + A O Y D j P 8 = < / l a t e x i t > w < l a t e x i t s h a 1 _ b a s e 6 4 = " K +i i v r h d e U P n W o x m B 5 C J Q N d K l 6 I = " > A A A B 6 H i c b V D L T g J B E O z F F + I L 9 e h l I j H x R H b R R I 9 E L x 4 h k U c C G z I 7 9 M L I 7 O x m Z l Z D C F / gx Y P G e P W T v P k 3 D r A H B S v p p F L V n e 6 u I B F c G 9 f 9 d n J r 6 x u b W / n t w s 7 u 3 v 5 B 8 f C o q e N U M W y w W

Figure 4: A brief example of the critic in EMD.

q xi , p xi ). • Averaged total approximation error (Avg.Model.Err.): The averaged MMD between teacher's particles (for each x) and locally fitted Dirichlet, i.e., 1 N N i=1 MMD(p xi , q * xi ). • Averaged local amortization gap (Avg.Amt.Gap): The difference between Avg.Approx.Err

y b |x b , θ (t) )) + η t ,

, where a parameterized Dirichlet is used in a Bayesian model to characterize the "distributional uncertainty", i.e., to tell if the data is in the training domain or not. However, DPN adds a stochastic layer in the Bayes model, rather than approximating a well-trained Bayes teacher. Due to the intractable inference, DPN uses an MAP estimate of the model posterior which incurs a loss of uncertainty. To compensate for the lost characterization of uncertainty, DPN uses a

Table content: <table/>

Results on BNN -MNIST. The doubt quote means "same as above".

Table content: <table><tr><td>Model</td><td>MisC detection AUROC AUPR AUROC AUPR AUROC AUPR Omniglot SEMEION</td><td colspan="2">Acc. (%) time(s) Test</td></tr><tr><td>MCDP-KL</td><td colspan="3">97.3 (E) 43.0 (E) 99.4 (D) 99.7 (D) 86.8(E) 53.8 (P) 97.9 210.6</td></tr><tr><td>MCDP-EMD</td><td colspan="2">97.3 (E) 43.0 (E) 99.6 (D) 99.9 (D) 86.8(E) 53.8 (P) 97.9</td><td>"</td></tr><tr><td>MCDP-MMD</td><td colspan="2">97.3 (E) 43.0 (E) 99.7 (D) 99.9 (D) 90.1 (D) 71.2 (D) 97.9</td><td>"</td></tr><tr><td>OPU-MCDP-KL</td><td colspan="3">94.2 (E) 37.7 (E) 100 (C) 77.0 (C) 91.4 (C) 67.3 (C) 96.2 0.443</td></tr><tr><td colspan="3">OPU-MCDP-EMD 95.3 (P) 43.7 (P) 100 (C) 100 (C) 93.3 (C) 82.5 (C) 96.1</td><td>"</td></tr><tr><td colspan="3">OPU-MCDP-MMD 97.2 (P) 40.9 (P) 100 (C) 100 (C) 99.8 (C) 98.6 (C) 97.9</td><td>"</td></tr><tr><td>SGLD-KL</td><td colspan="3">97.9 (P) 46.2 (E) 99.2 (E) 99.6 (E) 89.3 (E) 46.8 (E) 98.4 233.5</td></tr><tr><td>SGLD-EMD</td><td colspan="2">97.9 (E) 46.2 (E) 99.4 (D) 99.7 (D) 89.9 (D) 47.1 (D) 98.4</td><td>"</td></tr><tr><td>SGLD-MMD</td><td colspan="2">97.9 (E) 46.2 (E) 99.2 (E) 99.6 (E) 89.3 (E) 46.8 (E) 98.4</td><td>"</td></tr><tr><td>OPU-SGLD-KL</td><td colspan="3">94.2 (E) 46.7 (E) 100 (C) 100 (C) 99.5 (C) 98.4 (C) 98.2 0.443</td></tr><tr><td colspan="3">OPU-SGLD-EMD 93.7 (P) 44.4 (E) 100 (C) 100 (C) 98.9 (C) 96.2 (C) 98.0</td><td>"</td></tr><tr><td colspan="3">OPU-SGLD-MMD 97.2 (P) 44.6 (E) 100 (C) 100 (C) 99.1 (C) 98.0 (C) 98.1</td><td>"</td></tr><tr><td>BDK-SGLD</td><td colspan="3">85.9 (E) 46.6 (E) 46.1 (E) 41.7 (E) 35.3 (P) 46.5 (P) 92.1 0.441</td></tr><tr><td>BDK-MCDP</td><td colspan="2">86.9 (E) 41.1 (E) 47.5 (P) 44.1 (P) 43.3 (P) 47.2 (P) 92.4</td><td>"</td></tr><tr><td>BDK-DIR-SGLD</td><td colspan="2">89.9 (E) 40.0 (E) 95.4 (E) 96.4 (E) 74.7 (E) 38.3 (E) 94.1</td><td>"</td></tr><tr><td>DPN</td><td colspan="2">99.0 (E) 43.6 (E) 100 (E) 100 (E) 99.7 (E) 98.6 (E) 99.4</td><td>-</td></tr></table>

Results on BNN -Balanced EMNIST. Dirichlet without disentangling the mean and concentration, then train it with the same MC ensemble as OPU-SGLD. This is to show the benefits of explicit disentanglement. The NN architecture used by these models is an MLP with size 784-400-400-10, ReLU activations, and softmax outputs, followingBalan et al. (2015). For CM, we use an MLP with size 784-400-400-1. MCDP is trained by SGD with hyper-parameters: dropout-rate of 0.5, learning rate 5 × 10 -4 , mini-batch size of 256, number of iterations 10 3 . The parameters of critic are shown in Appendix.

Table content: <table><tr><td>Model</td><td>MisC detection AUROC AUPR</td><td>AUROC</td><td>Omniglot</td><td>AUPR</td><td>Acc. (%)</td></tr><tr><td>MCDP-KL</td><td>89.7 (P) 46.8 (P)</td><td>99.7 (E)</td><td/><td>99.7 (E)</td><td>88.8</td></tr><tr><td>MCDP-MMD</td><td>89.7 (P) 46.8 (P)</td><td>99.9 (D)</td><td/><td>99.9 (D)</td><td>88.8</td></tr><tr><td>OPU-MCDP-KL</td><td colspan="5">84.8 (P) 40.6 (P) 96.2 (E) /67.5 (C) 96.5 (E) /63.7 (C) 87.9</td></tr><tr><td colspan="2">OPU-MCDP-MMD 89.8 (P) 49.6 (P)</td><td>100.0 (C)</td><td/><td>100 (C)</td><td>88.4</td></tr></table>

This further validates the necessity of explicit disentanglement of mean and concentration. OPU vs DPN. Our OPU model (without OOD data in training) has comparable performance to DPN (which uses a hand-crafted goal and OOD data in training). Another reason that DPN performs slightly better is that DPN uses VGG-6 (4 Convolutional layer and 1 FC layer), which is a much stronger model than the 2-layer MLP model that other models use. KL vs EMD vs MMD. With MCDP, MCDP-MMD gives the best performance of differential entropy baseline (D

Table content: <table/>

NikoSünderhauf, Oliver Brock, Walter Scheirer, Raia Hadsell, Dieter Fox, Jürgen Leitner, Ben  Upcroft, Pieter Abbeel, Wolfram Burgard, Michael Milford, et  al. The limits and potentials of deep learning for robotics. The International Journal of Robotics Research, 37(4-5):405-420, 2018. Ilya Tolstikhin, Olivier Bousquet, Sylvain Gelly, and Bernhard Schoelkopf. Wasserstein auto-encoders. arXiv preprint arXiv:1711.01558, 2017. Cédric Villani. Optimal transport: old and new, volume 338. Springer Science & Business Media, 2008. Max Welling and Yee Whye Teh. Bayesian learning via stochastic gradient Langevin dynamics. In Proceedings of the 28nd international conference on Machine learning, pp. 681-688. ACM, 2011.

Table content: <table/>

Results on Bayesian logistic regression models.

Table content: <table><tr><td>Data</td><td>Model</td><td>MisC detection AUROC AUPR</td><td colspan="2">OOD detection AUROC AUPR</td><td>Acc. (%)</td><td>Time (sec.)</td></tr><tr><td/><td>PG</td><td>60.0 (Ent) 24.2 (Ent)</td><td>87.0 (Ent)</td><td>76.7 (Ent)</td><td colspan="2">64.4 1.01 ± 0.001</td></tr><tr><td>Pima</td><td>CA-PG</td><td>58.2 (Ent) 24.2 (Ent)</td><td>80.1 (Ent)</td><td>74.5 (Ent)</td><td colspan="2">62.3 0.18 ± 0.001</td></tr><tr><td/><td colspan="5">OPU-PG 59.7 (Ent) 25.6 (Ent) 100.0 (CM) 100.0 (CM) 64.4</td><td>0.01±0.002</td></tr><tr><td/><td>PG</td><td>83.9 (Ent) 24.3 (Ent)</td><td>54.6 (Ent)</td><td>53.5 (Ent)</td><td colspan="2">92.4 5.94 ± 0.001</td></tr><tr><td>Spam</td><td>CA-PG</td><td>64.1 (Ent) 24.2 (Ent)</td><td>71.5 (Ent)</td><td>67.5 (Ent)</td><td colspan="2">85.4 0.36 ± 0.001</td></tr><tr><td/><td colspan="2">OPU-PG 83.9 (Ent) 23.8 (Ent)</td><td>99.7 (CM)</td><td>99.3 (CM)</td><td>92.4</td><td>0.01±0.002</td></tr></table>

Results on Gaussian process classification models.

Table content: <table><tr><td>Data</td><td>Model</td><td>MisC detection AUROC AUPR</td><td colspan="2">OOD detection AUROC AUPR</td><td>Acc. (%)</td><td>Time (second)</td></tr><tr><td/><td>SGPMC</td><td>65.3 (E) 46.4 (E)</td><td>96.7 (E)</td><td>94.9 (E)</td><td>79.3</td><td>0.003</td></tr><tr><td>Pima</td><td>SVGP</td><td>64.3 (E) 43.2 (E)</td><td>96.0 (E)</td><td>91.1 (E)</td><td>77.1</td><td>0.004</td></tr><tr><td/><td colspan="5">OPU-SGPMC 65.7 (E) 44.4 (E) 100.0 (C) 100.0 (C) 79.2</td><td>0.010</td></tr><tr><td/><td>SGPMC</td><td>86.7 (E) 37.8 (E)</td><td>98.6 (E)</td><td>97.6 (E)</td><td>92.4</td><td>0.056</td></tr><tr><td>Spam</td><td>SVGP</td><td>86.2 (E) 33.3 (E)</td><td>99.2 (E)</td><td>98.5 (E)</td><td>92.1</td><td>0.032</td></tr><tr><td/><td colspan="5">OPU-SGPMC 86.5 (E) 39.5 (E) 100.0 (C) 100.0 (C) 92.0</td><td>0.011</td></tr></table>

Results on error/gap on EMNIST. Avg.Approx.Err. Avg.Model.Err. Avg.Amt.Gap Avg.Amt.Err.

Table content: <table><tr><td>0.0650</td><td>0.0601</td><td>0.0049</td><td>0.0053</td></tr><tr><td colspan="3">D.3 MORE EXPERIMENTS ON BAYESIAN NEURAL NETWORK</td><td/></tr><tr><td colspan="4">In this section, we present more experimental results/details on Bayesian NN.</td></tr></table>

Results on BNN -Cifar10.

Table content: <table><tr><td>Model</td><td>MisC detection AUROC AUPR</td><td colspan="3">OOD detection LSUN Acc. AUROC AUPR (%)</td></tr><tr><td>MCDP-KL</td><td colspan="2">92.2 (P) 47.0 (P) 90.5 (E)</td><td>88.7 (E)</td><td>92.4</td></tr><tr><td>MCDP-EMD</td><td colspan="2">92.2 (P) 47.0 (P) 91.4 (D)</td><td>89.1 (D)</td><td>92.4</td></tr><tr><td>MCDP-MMD</td><td colspan="2">92.2 (P) 47.0 (P) 91.0 (D)</td><td>89.3 (D)</td><td>92.4</td></tr><tr><td>OPU-MCDP-KL</td><td colspan="2">87.2 (P) 45.9 (P) 86.1 (E)</td><td>85.5 (E)</td><td>89.9</td></tr><tr><td>OPU-MCDP-EMD</td><td colspan="2">91.8 (E) 46.9 (P) 93.5 (C)</td><td>92.0 (C)</td><td>91.8</td></tr><tr><td colspan="3">OPU-MCDP-MMD 91.3 (E) 46.6 (P) 92.9 (C)</td><td>91.7 (C)</td><td>91.8</td></tr></table>

Results on MNIST -MCDP/SGLD with fewer samples.

Table content: <table><tr><td colspan="2">Model MisC detection</td><td>Omniglot</td><td>SEMEION</td><td>Acc.</td><td>Time</td></tr><tr><td/><td>AUROC</td><td>AUROC</td><td>AUROC</td><td>(%)</td><td>s</td></tr><tr><td>MCDP</td><td>96.1 (-1.2)</td><td/><td/><td/></tr></table>

Results on MNIST -undistilled MCDP/SGLD. MCDP 97.3 (E) 43.0 (E) 99.2 (E) 98.8 (P) 86.8 (E) 53.8 (P) 97.9 SGLD 97.9 (E) 46.2 (E) 99.2 (E) 99.6 (E) 89.3 (E) 46.8 (E) 98.4

Table content: <table><tr><td>Model</td><td>MisC detection AUROC AUPR AUROC AUPR AUROC AUPR Omniglot SEMEION</td><td>Acc. (%)</td></tr></table>

Peer review (iclr2020):
Thank the authors for your detailed rebuttal. I agree with the authors that the proposed method acts as a useful tool for *real-time evaluation of induced predictive uncertainty*, and the experiments also validate that the method indeed achieves comparable performance with smaller computations. But for now, I am inclined to not change my score. ################### Bayesian models maintain the posterior distribution for predictions, which might bring up big computational costs of multiple forwards or big memory costs of multiple particles. To resolve the computational and memory issues at predictions, this paper proposes to distill Bayesian models into an amortized prediction model, avoiding the original multiple forwards. Specifically, in classification, they distill the predictive probabilities into an amortized Dirichlet distribution. They evaluated different distillation metrics, including KL divergence, Earth moving distance, and Maximum mean discrepancy. Empirically, they evaluate the proposed method over out-of-distribution detection. They demonstrate that their method achieves comparable performance with much speedup. Strengths, 1, This paper is well-written and the ideas are well-presented. They evaluated the proposed method over different Bayesian models (MCDP & SGLD) as well different metrics (KL, EMD, MMD), and demonstrate the effectiveness of their method. Overall, this paper is very comprehensive. 2, As evaluated and validated in the experiments, the proposed method vastly reduces the inference time at test phase. Weakness, 1, The paper kind of lacks of novelty. Basically the proposed method distills a Bayesian models into an amortized Dirichlet distribution, which is straightforward. 2, The baselines such as MCDP-KL, MCDP-EMD are strange, it is wired why you would distill the predictive distribution of a single point to a Dirichlet distribution. And I think it is probably unfair, as distilling the single-point distribution to the Dirichlet under KL, EMD, MMD might require large amount of particles, which they don*t have. 3, Related to (2), more baselines should be compared with to better demonstrate the method*s effectiveness. 1) performance of the un-distilled MCDP and SGLD models. 2) BDK and DPN for the MCDP models. 3) MCDP and SGLD with fewer particles. The paper claims to achieve 500x speed up, while I reckon the performance of MCDP and SGLD won*t deteriorate a lot if you use only fewer particles. 4, It would be interesting to see experiments other than out-of-distribution detection, such as calibration. Minor Issues, 1, The paper has several un-complied references, such as above eq(4) and appendix D. 2, The Tau(x | 	heta) in Figure 1 is a typo. 3, Assumption 1 should be put forward to the main articles for comprehensiveness of Lemma 1.