Year: 2021

Abstract:
Uncertainty awareness is crucial to develop reliable machine learning models. In this work, we propose the Natural Posterior Network (NatPN) for fast and highquality uncertainty estimation for any task where the target distribution belongs to the exponential family. Thus, NatPN finds application for both classification and general regression settings. Unlike many previous approaches, NatPN does not require out-of-distribution (OOD) data at training time. Instead, it leverages Normalizing Flows to fit a single density on a learned low-dimensional and taskdependent latent space. For any input sample, NatPN uses the predicted likelihood to perform a Bayesian update over the target distribution. Theoretically, NatPN assigns high uncertainty far away from training data. Empirically, our extensive experiments on calibration and OOD detection show that NatPN delivers highly competitive performance for classification, regression and count prediction tasks.

text: 1 INTRODUCTION
Accurate and rigorous uncertainty estimation is key for reliable machine learning models in safety-critical domains [48]. It quantifies the confidence of machine learning models, thus allowing them to validate knowledgeable predictions corresponding to correct/wrong predictions, flag predictions on unknown input domains corresponding to anomaly or Out-ofDistribution detection, or detect natural shifts of the data facilitating real-time model maintenance (Filos et al., 2019; Malinin et al., 2021; Ovadia et al., 2019). Specifically, a reliable model can handle all these failure modes with high-quality estimates of aleatoric and epistemic uncertainty (Gal, 2016). These two levels of uncertainty allow a model to account for both irreducible data uncertainty (e.g. a fair dice’s chance of 1/6 for each face) and uncertainty due to the lack of knowledge about unseen data (e.g. input features differing significantly from training data or a covariate shift) respectively. Aleatoric and epistemic uncertainty levels can eventually be combined into an overall predictive uncertainty (Gal, 2016)
Traditional neural networks are not readily applicable in safety-critical domains as they show overconfident prediction, in particular on data that is different from training data (Guo et al., 2017; Lakshminarayanan et al., 2017). To mitigate this problem, an important model family for uncertainty estimation directly pre-
dicts the parameters of a conjugate prior distribution on the predicted target probability distribution, thus accounting for the different levels of uncertainty. These models are efficient as they only require a
single forward pass for target and uncertainty prediction. Most of those models focus on classification and thus predict parameters of a Dirichlet distribution (Biloš et al., 2019; Charpentier et al., 2020; Gast & Roth, 2018; Malinin & Gales, 2018; 2019; Nandy et al., 2020; Sensoy et al., 2020; Shi et al., 2020; Zhao et al., 2020b). However, only two works (Amini et al., 2020; Malinin et al., 2020a) have focused on regression by learning parameters of a Normal Inverse-Gamma (NIG) distribution as conjugate prior. Hence, all these models are limited to a single task (e.g. either classification or regression). Some approaches even require out-of-distribution (OOD) data at training time (Malinin & Gales, 2018; 2019) which is an unrealistic assumption in many real-world applications where anomalies are a priori diverse, rare or unknown.
Our contribution. We propose Natural Posterior Network (NatPN) as a new approach parametrizing conjugate prior distributions for versatile uncertainty estimation. NatPN is motivated from both the theoretical and practical perspective. (1) NatPN can estimate predictive uncertainty for any task described by the general group of exponential family distributions contrary to existing approaches from this family of models. Notably, this encompasses very common tasks such as classification, regression and count prediction which can be described with Categorical, Normal and Poisson distributions, respectively. (2) In theory, NatPN is based on a new unified exponential family framework which performs an input-dependent Bayesian update. For every input, it predicts the parameters of the posterior over the target exponential family distribution. We show that this Bayesian update is guaranteed to predict high uncertainty far from training data. (3) In practice, NatPN requires no OOD data for training, only adds a single normalizing flow density to the last predictor layer and provides fast uncertainty estimation in a single forward pass. Our extensive experiments showcase the high performances of NatPN for various criteria (accuracy, calibration, OOD and shift detection) and tasks (classification, regression and count prediction). We illustrate the accurate aleatoric and predictive uncertainty predictions of NatPN on two toy examples for classification and regression in Fig. 1. None of the conjugate prior related works have similar theoretical and practical properties.

heading: 2 RELATED WORK
text: In this section, we describe other work related to uncertainty estimation for supervised learning. We refer to Gawlikowski et al. (2021) for a detailed survey on uncertainty estimation in deep learning.
Sampling-based methods. A first family of models estimates uncertainty by aggregating statistics (e.g. mean and variance) from different samples of an implicit predictive distribution. Examples are ensemble (Kim & Ghahramani, 2012; Lakshminarayanan et al., 2017; Simpson et al., 2012; Wen et al., 2020; Wenzel et al., 2020) and dropout (Gal & Ghahramani, 2016) models which provide high-quality uncertainty estimates (Ovadia et al., 2019) at the cost of an expensive sampling phase at inference time. Moreover, ensembles usually require training multiple models. Further, Bayesian neural networks (BNN) (Blundell et al., 2015; Maddox et al., 2019; Ritter et al., 2018) model the uncertainty on the weights and also require multiple samples to estimate the uncertainty on the final prediction. While recent BNNs have shown reasonably good performance (Dusenberry et al., 2020; Farquhar et al., 2020; Osawa et al., 2019), modelling the distribution on the weights suffers from pathological behavior thus limiting these approaches in practice (Foong et al., 2020; Graves, 2011; Izmailov et al., 2021). In particular, Izmailov et al. (2021) uses an enormous computation budget by parallelizing the computation over 512 TPUv3 devices and running tens of thousands of training epochs to achieve a more exact Bayesian inference which is not suitable for practical applications. In contrast, NatPN predicts uncertainty in a single forward pass with a closed-form posterior distribution over the target variable. NatPN does not model uncertainty on the weights.
Sampling-free methods. A second family of models is capable of estimating uncertainty in a single forward pass. The family of models parametrizing conjugate prior distributions is the main focus of this paper (Amini et al., 2020; Biloš et al., 2019; Charpentier et al., 2020; Gast & Roth, 2018; Malinin & Gales, 2018; 2019; Malinin et al., 2020a; Nandy et al., 2020; Sensoy et al., 2020; Shi et al., 2020; Zhao et al., 2020b). Beyond this family of models, we differentiate between three other families of sampling-free models for uncertainty estimation. A family of models aims at learning deep Gaussian processes by learning random features projections or by learning inducing points (Biloš et al., 2019; Lakshminarayanan et al., 2020; van Amersfoort et al., 2020; 2021). Another family of models aims at propagating uncertainty across layers (Gast & Roth, 2018; Hernandez-Lobato & Adams, 2015; Postels et al., 2019; Shekhovtsov & Flach, 2019; Wang et al., 2016). They model uncertainty at
the weight and/or activation levels and are generally constrained to specific transformations. In contrast, NatPN only models the uncertainty on the predicted target variable and does not enforce any constraint on the encoder architecture. Further, some of the models propagating uncertainty already used the exponential family framework (Ranganath et al., 2015; Wang et al., 2016). However, while they parametrize exponential family distributions, NatPN parametrizes the conjugate prior of the target exponential family distributions which accounts for the epistemic uncertainty. Finally, while the family of calibration models aims at calibrating predictions (Kuleshov et al., 2018; Moon et al., 2020; Rahimi et al., 2020; Song et al., 2019; Zhao et al., 2020a), NatPN aims at accurately modelling both aleatoric and epistemic uncertainty on in- and out-of-distribution data.

heading: 3 NATURAL POSTERIOR NETWORK
text: At the very core of NatPN stands the Bayesian update rule: Q(θ | D) ∝ P(D |θ) × Q(θ) where P(D |θ) is the target distribution of the target data D given its parameter θ, and Q(θ) and Q(θ | D) are the prior and posterior distributions, respectively, over the target distribution parameters. The target distribution P(D |θ) could be any likelihood describing the observed target labels. The Bayesian update has three main advantages: (1) it introduces a prior belief which represents the safe default prediction if no data is observed, (2) it updates the prior prediction based on observed target labels, and (3) it assigns a confidence for the new target prediction given the aggregated evidence count of observed target labels. While NatPN is capable to perform a Bayesian update for every possible input given the observed training data, we first recall the Bayesian background for a single exponential family distribution.

heading: 3.1 EXPONENTIAL FAMILY DISTRIBUTION
text: Distributions from the exponential family are very widely used and have favorable analytical properties. Indeed, (1) they cover a wide range of target variables like discrete, continuous, counts or spherical coordinates, and (2) they benefit from intuitive and generic formulae for their parameters, density functions and statistics which can often be evaluated in closed-form. Important examples of exponential family distributions are Normal, Categorical and Poisson distributions (see Tab. 1). Formally, an exponential family distribution on a target variable y ∈ R with natural parameters θ ∈ RL can be denoted as
P(y |θ) = h(y) exp ( θTu(y)−A(θ) ) (1)
where h : R→ R is the carrier or base measure, A : RL → R the log-normalizer and u : R→ RL the sufficient statistics (Bishop, 2006; Nielsen & Nock, 2010). The entropy of an exponential family distribution can always be written as H[P] = A(θ)− θT∇θA(θ)− E[log h(y)] (Nielsen & Nock, 2010). An exponential family distribution always admits a conjugate prior, which often also is a member of the exponential family:
Q(θ |χ, n) = η(χ, n) exp ( nθTχ− nA(θ) ) (2)
where η(χ, n) is a normalization coefficient, χ ∈ RL are prior parameters and n ∈ R+ is the evidence. Given a set of N target observations {y(i)}Ni , it is easy to compute a closed-form Bayesian update Q(θ |χpost, npost) ∝ P({y(i)}Ni |θ)×Q(θ |χprior, nprior):
Q(θ |χpost, npost) ∝ exp ( npostθTχpost − npostA(θ) ) (3)
where χpost = npriorχprior+
∑N
j u(y (j))
nprior+N and n post = nprior + N . We see that χprior (resp. χpost) can be
viewed as the average sufficient statistics of nprior (resp. npost) fictitious samples (Bishop, 2006). Further, the average sufficient statistic of fictitious samples is equal to the expected sufficient statistic of the conjugate distribution, i.e. χ = EQ(χ,n)[θ] (Brown, 1986; Diaconis & Ylvisaker, 1979). Thus, the parameter χpost carries the inherent aleatoric uncertainty on the target distribution with natural parameters θ, while the evidence npost aligns well with the epistemic uncertainty (i.e. a low evidence means few prior target observations). We stress that the natural conjugate prior parametrization χ, n is often different from the “well-known” parametrization κ used by standard coding libraries. By definition, a bijective mapping m(κ) = (χ, n) from the natural parametrization to the commonly used parametrization always exists (see examples in Tab. 1). Finally, exponential family distributions always admit a closed-form posterior predictive distribution (Gelman et al., 2004).

heading: 3.2 INPUT-DEPENDENT BAYESIAN UPDATE FOR EXPONENTIAL FAMILY DISTRIBUTIONS
text: We propose to leverage the power of exponential family distributions for the more complex task when the prediction y(i) depends on the input x(i). Hence, NatPN extends the Bayesian treatment of a single exponential family distribution prediction by predicting an individual posterior update per input. We distinguish between the chosen prior parameters χprior, nprior shared among samples, and the additional predicted parameters χ(i), n(i) dependent on the input x(i) leading to the updated posterior parameters:
χpost,(i) = npriorχprior + n(i)χ(i)
nprior + n(i) , npost,(i) = nprior + n(i) (4)
Equivalently, NatPN may be interpreted as predicting a set of n(i) pseudo observations {y(j)}(i)j such that their aggregated sufficient statistics satisfy ∑n(i) j y
(j) = n(i)χ(i), and perform the respective Bayesian update. This Bayesian update works for any choice of exponential family distributions as long as parameters are mapped to their standard form (see Tab. 1). According to the principle of maximum entropy (Rosenkrantz, 1989), a practical choice for the prior is to enforce high entropy for the prior distribution which is usually considered less informative. It is typically achieved when the prior pseudo-count nprior is small and the prior parameter χprior shows a high aleatoric uncertainty.
Hence, NatPN proposes a generic way to perform the input-dependent Bayesian update χ(i), n(i) for any exponential family distribution in three steps (see Fig. 2): (1) An encoder fφ maps the input x(i) onto a low-dimensional latent vector z(i) = fφ(x(i)) ∈ RH representing useful features for the prediction task (see left Fig.2). Note that the architecture of the encoder can be arbitrarily complex. Then, (2) the latent representation z(i) is used in two different ways to predict the parameter update χ(i) and the evidence update n(i) (see center Fig.2). On the one hand, a linear decoder gψ is trained to output the parameter update χ(i) = gψ(z(i)) ∈ RL accounting for the aleatoric uncertainty. On the other hand, a single normalized density is trained to output the evidence update n(i) = NH P(z(i) |ω) accounting for the epistemic uncertainty. The intuition is that increasing the evidence on training data during training forces the evidence everywhere else (incl. far from
training data) to decrease thanks to the density normalization constraint. The constant NH is a certainty budget distributed by the normalized density P(z(i) |ω) over the latent representations z(i) i.e. NH = ∫ NH P(z(i) |ω)dz(i) = ∫ n(i)dz(i). In practice, we observed that scaling the certainty budget w.r.t. the latent dimension H helped the density to cover larger volumes in higher dimension (see app.). Finally, (3) NatPN computes the posterior parameters χpost,(i) and npost,(i) which can be viewed respectively as the mean and concentration of the posterior distribution (see right Fig.2). Note that the posterior parameter χpost,(i) is a simple weighted average of the prior parameter χprior and the update parameter χ(i) as shown by Eq. 4.
NatPN extends PostNet (Charpentier et al., 2020) which also performs an input-dependent Bayesian update with density estimation. Yet, it has three crucial differences which lead to major practical improvements. First, the new exponential family framework is significantly more flexible and is not restricted to classification. Second, the Dirichlet α parameter computation is different: NatPN computes the χ parameters – which can be viewed as standard softmax output – and the n evidence separately (i.e. α = nχ) while PostNet computes one evidence pseudo-count per class. Third, NatPN is computationally more efficient. It requires a single density while PostNet requires C densities.

heading: 3.3 ID AND OOD UNCERTAINTY ESTIMATES
text: NatPN intuitively leads to reasonable uncertainty estimation for the two limit cases of strong indistribution (ID) and out-of-distribution (OOD) inputs (see red and purple samples in Fig. 2). For very likely in-distribution data (i.e. P(z(i) |ω)→∞), the posterior parameter overrules the prior (i.e. χpost,(i) → χ(i)). Conversely, for very unlikely out-of-distribution data (i.e. P(z(i) |ω) → 0), the prior parameter takes over in the posterior update (i.e. χpost,(i) → χprior). Hence, the choice of the prior parameter should reflect the default prediction when the model lacks knowledge. We formally show under mild assumptions on the encoder that NatPN predicts very low additional evidence (n(i) ≈ 0) for (almost) any input x(i) far away from the training data (i.e. ||x(i)|| → +∞), thus recovering prior predictions (i.e. χpost,(i) ≈ χprior) (see proof in app.). Theorem 1. Let a NatPN model be parametrized with a (deep) encoder fφ with ReLU activations, a decoder gψ and the density P(z |ω). Let fφ(x) = V (l)x+a(l) be the piecewise affine representation of the ReLU network fφ on the finite number of affine regions Q(l) (Arora et al., 2018). Suppose that V (l) have independent rows and the density function P(z |ω) has bounded derivatives, then for almost any x we have P(fφ(δ · x) |ω) →
δ→∞ 0. i.e the evidence becomes small far from training data.
This theorem only requires that the density avoids very unlikely pathological behavior with unbounded derivatives (Dix, 2013). A slightly weaker conclusion holds using the notion of limit in density if the density function does not have bounded derivatives (Niculescu & Popovici, 2011). Finally, the independent rows condition is realistic for trained networks with no constant output (Hein et al., 2019). It advantageously leads NatPN to consistent uncertainty estimation contrary to standard ReLU networks which are overconfident far from training data (Hein et al., 2019).

heading: 3.4 BAYESIAN NATPN ENSEMBLE
text: Interestingly, it is natural to extend the Bayesian treatment of a single NatPN to an ensemble of NatPN models (NatPE). An ensemble of m NatPN models is intuitively equivalent to performing m successive Bayesian updates using each NatPN member separately. More formally, given an input x(i) and an ensemble of m jointly trained NatPN models, the Bayesian update for the posterior distribution becomes χpost,(i) = n priorχprior+ ∑m k n (i) k χ (i) k
nprior+ ∑m
k n (i) k
and npost,(i) = nprior + ∑m k n (i) k . Note that
the standard Bayesian averaging which is used in many ensembling methods (Chipman et al., 2007; Lakshminarayanan et al., 2017; Wen et al., 2020; Wenzel et al., 2020) is different from this Bayesian combination. While Bayesian averaging assume that only one model is correct, the Bayesian combination of NatPN allows more or none of the models to be “expert” for some input (Monteith et al., 2011). For example, an input x(i) unfamiliar to every model m (i.e. n(i)m ≈ 0) would recover the prior default prediction χprior, nprior. Existing models already had similar properties for Bayesian combination of classifiers (Kim & Ghahramani, 2012; Simpson et al., 2012).

heading: 3.5 OPTIMIZATION
text: The choice of the optimization procedure is of primary importance in order to obtain both high-quality target predictions and uncertainty estimates regardless of the task.
Bayesian Loss. We follow Charpentier et al. (2020) and aim at minimizing the Bayesian formulation:
L(i) = −Eθ(i)∼Qpost,(i) [logP(y(i) |θ(i))]︸ ︷︷ ︸ (i) −H[Qpost,(i)]︸ ︷︷ ︸ (ii)
(5)
where H[Qpost,(i)] denotes the entropy of the predicted posterior distribution Qpost,(i). Similarly to the ELBO loss, this loss is guaranteed to be optimal when the predicted posterior distribution is close to the true posterior distribution Q∗(θ |x(i)) i.e. Qpost,(i) ≈ Q∗(θ |x(i)) (Bissiri et al., 2016; Shawe-Taylor & Williamson, 1997; Zellner, 1988). However, this loss is generally not equal to the ELBO loss especially for real valued targets i.e. y ∈ R (see app.). The term (i) is the expected likelihood under the predicted posterior distribution. It can be viewed as the Uncertain Cross Entropy (UCE) loss (Biloš et al., 2019) which is known to reduce uncertainty on observed data. The term (ii) is an entropy regularizer acting as a prior which favors uninformative distributions Qpost,(i) with high entropy. In our case, we assume the likelihood P(y(i) |θ(i)) and the posterior Qpost,(i) to be members of the exponential family. We take advantage of the convenient computations for such distributions and derive a more explicit formula for the Bayesian formulation (5) (see derivation in the appendix):
L(i)λ ∝ E[θ] Tu(y(i))− E[A(θ)]− λH[Qpost,(i)] (6)
where λ is an additional regularization weight tuned with a grid search. Note that the term E[θ]Tu(y(i)) favors a good alignment of the expected sufficient statistic E[θ] = χ with the observed sufficient statistic u(y(i)). In practice, all terms can be computed efficiently in closed form for most exponential family distributions (see examples in Tab. 1). In particular, simplifications are possible when the conjugate prior distribution is also in an exponential family which is often the case. Ultimately Eq. (6) applies to any exponential family distribution unlike Charpentier et al. (2020).
Optimization Scheme. NatPN is fully differentiable using the closed-form Bayesian loss. Thus, we train the encoder fφ, the parameter decoder gψ and the normalizing flow P(z(i) |ω) w.r.t. parameters φ,ψ,ω jointly. Further, we observed that “warm-up training” (Ash & Adams, 2020) and “fine-tuning” (Käding et al., 2016) of the density helped to improve uncertainty estimation for more complex flows and datasets. Thus, we train the normalizing flow density to maximize the likelihood of the latent representations before and after the joint optimization while keeping all other parameters fixed.

heading: 3.6 MODEL LIMITATIONS
text: Task-Specific OOD. Previous works show that density estimation is unsuitable for acting on the raw image input (Choi et al., 2019; Nalisnick et al., 2019; 2020) or on a non-carefully transformed space (Lan & Dinh, 2020). To circumvent this issue, NatPN does not perform OOD detection directly on the input but rather fits a normalizing flow on a learned space. In particular, the latent space is (1) low-dimensional, (2) task-specific and (3) encodes meaningful semantic features. Similarly, Charpentier et al. (2020); Kirichenko et al. (2020); Morningstar et al. (2020); Winkens et al. (2020) already improved OOD detection of density-based methods by leveraging a task-induced bias or low-dimensional statistics. In the case of NatPN, the low-dimensional latent space has to contain relevant features to linearly predict the sufficient statistics required for the task. For example, NatPN aims at a linearly separable latent space for classification. The downside is that NatPN is capable of detecting OOD samples only with respect to the considered task and requires labeled examples during training. As an example, NatPN likely fails to detect a change of image color if the task aims at classifying object shapes and the latent space has no notion of color. Hence, we underline that NatPN comes with a task-dependent OOD definition, which is a reasonable choice in practice.
Model-Task Mismatch. Second, we emphasize that the uncertainty estimation quality of NatPN for (close to) ID data depends on the convergence of the model, the encoder architecture (e.g. MLP, Conv., DenseDepth (Eigen et al., 2014)) and the target distribution (e.g. Poisson, Normal distributions) choice which should match the task needs. However, we show empirically that NatPN provides high quality uncertainty estimates in practice on a wide range of tasks. Further, we show theoretically that
NatPN leads to uncertain prediction far away from training data for any exponential family target distributions. In comparison, Meinke & Hein (2020) showed akin guarantees for classification only.

heading: 4 EXPERIMENTS
text: In this section, we compare NatPN to existing methods on extensive experiments including three different tasks: classification, regression and count prediction. For each task type, we evaluate the prediction quality based on target error and uncertainty metrics. These various set-ups aim to highlight the versatility of NatPN. In particular, NatPN is the only model that adapts to all tasks and achieves high performances for all metrics without requiring multiple forward passes.
1 2 3 4 5 30%
40%
50%
60%
70%
80%
A cc
ur ac
y
1 2 3 4 5 30%
40%
50%
60%
70%
80%
R el
at iv
e C
o nf
id en
ce
0.0 0.2 0.4 0.6 0.8 1.0 Severity of Perturbations
0.0
0.2
0.4
0.6
0.8
1.0
R-PriorNet EnD2 PostNet NatPN
Figure 3: Averaged accuracy and confidence under 15 dataset shifts on CIFAR-10 (Hendrycks & Dietterich, 2019). On more severe perturbations (i.e. data further away from data distribution), NatPN maintains a competitive accuracy while assigning higher epistemic uncertainty as desired. Baselines provide a slower relative confidence decay.
In our experiments, we change the encoder architecture of NatPN to match the dataset needs. We perform a grid search over normalizing flows types (i.e. radial flows (Rezende & Mohamed, 2015) and MAF (Germain et al., 2015; Papamakarios et al., 2017)) and latent dimensions. We show further experiments on architecture, latent dimension, normalizing flow choices and certainty budget choice in the appendix. Furthermore, we use approximations of the log-Gamma log Γ(x) and the Digamma ψ(x) functions for large input values to avoid unstable floating computations (see app.). As prior parameters, we set χprior = 1C/C, nprior = C for classification, χprior = (0, 100)T , nprior = 1 for regression and χprior = 1, nprior = 1 for count prediction enforcing high entropy for prior distributions.
Baselines. We focus on recent models parametrizing prior distributions over the target distribution. For classification, we compare NatPN to Reverse KL divergence Prior Networks (R-PriorNet) (Malinin & Gales, 2019), Ensemble Distribution Distillation (EnD2) (Malinin et al., 2020b) and Posterior Networks (PostNet) (Charpentier et al., 2020). Note that Prior Networks require OOD training data — we use an auxiliary dataset when available and Gaussian noise otherwise. For regression, we compare to Evidential Regression (EvReg) (Amini et al., 2020). Beyond baselines parametrizing conjugate prior distributions, we also compare to dropout (Dropout) (Gal & Ghahramani, 2016) and ensemble (Ensemble) (Lakshminarayanan et al., 2017) models for all tasks. These sampling baselines require multiple forward passes for uncertainty estimation. Further details are given in the appendix.
Datasets. We split all datasets into train, validation and test sets. For classification, we use one tabular dataset (Sensorless Drive (Dua & Graff, 2017)) and three image datasets (MNIST (LeCun et al., 2010), FMNIST (Xiao et al., 2017) and CIFAR-10 (Krizhevsky et al., 2009)). For count prediction, we use the Bike Sharing dataset (Fanaee-T & Gama, 2014) to predict the number of bike rentals within an hour. For regression, we also use the Bike Sharing dataset where the target is viewed as continuous, real-world UCI datasets used in Amini et al. (2020); Hernandez-Lobato & Adams (2015) and the image NYU Depth v2 dataset (Nathan Silberman & Fergus, 2012) where the goal is to predict the image depth per pixel. All inputs are rescaled with zero mean and unit variance. We also scale the output target for regression. Further details are given in the appendix.
Metrics. Beyond the target prediction error, we evaluate model uncertainty estimation using calibration and OOD detection scores. Furthermore, we report the inference speed. Further results including histograms with uncertainty estimates or latent space visualization are presented in appendix. Target error: We use the accuracy (Accuracy) for classification and the Root Mean Squared Error (RMSE) for regression and count prediction. Calibration: For classification, we use the Brier score (Brier) (Gneiting & Raftery, 2007). For regression and count prediction, we use the quantile calibration score (Calibration) (Kuleshov et al., 2018). OOD detection: We evaluate how the uncertainty scores enable to detect OOD data using the area under the precision-recall curve (AUC-PR) the area under the receiver operating characteristic curve (AUC-ROC) in the appendix. We use two different uncertainty measures: the negative entropy of the predicted target distribution accounting for the aleatoric uncertainty (Alea. OOD) and the predicted evidence or variance of the predicted mean (Epist. OOD). Similarly to (Charpentier et al., 2020; Ovadia et al., 2019), we use four different types of clear OOD samples: Unseen datasets (KMNIST Clanuwat et al. (2018), Fashion-MNIST (Xiao et al., 2017), SVHN (Netzer et al., 2011), LSUN (Yu et al., 2015), CelebA (Liu et al., 2015), KITTI (Geiger et al., 2013)), left-out data (classes 9/10 for Sensorless Drive, winter/spring/autumn seasons for Bike Sharing), out-of-domain data not normalized in [0, 1] (OODom) and dataset shifts (corrupted CIFAR-10 (Hendrycks & Dietterich, 2019)). Further details are given in the appendix.

heading: 4.2 RESULTS
text: Classification. We show results for the tabular dataset Sensorless Drive with unbounded input domain in Tab. 2, and the image datasets MNIST, FMNIST and CIFAR-10 with bounded input domain in
Tab. 3 and appendix. Overall, for classification NatPN performs on par with best single-pass baselines (i.e. 12/30 top-1 scores, 25/30 top-2 scores) and NatPE performs the best among multiple-pass models (i.e. 28/30 top-1 scores). A single NatPN achieves accuracy and calibration performance on par with the most calibrated baselines, namely PostNet and R-PriorNet which requires one normalizing flow per class or training OOD data. Further, NatPE consistently improves accuracy and calibration performance of a single NatPN which underlines the benefit of aggregating multiple models predictions for accuracy and calibration (Lakshminarayanan et al., 2017). Without requiring OOD data during training, both NatPN and NatPE achieve excellent OOD detection scores w.r.t. all OOD types. This strongly suggests that NatPN does not suffer from the flaws in Choi et al. (2019); Nalisnick et al. (2019; 2020). In particular, NatPN and NatPE achieve almost perfect OODom scores contrary to all other baselines except PostNet. This observation aligns well with the theoretical guarantee of NatPN far from training data (see Thm. 1) which also applies to each NatPE member. The similar performance of NatPN and PostNet for classification is intuitively explained by their akin design: both models perform density estimation on a low-dimensional latent space. Similarly to Charpentier et al. (2020), we compute the average confidence avg-conf = 1N ∑N i n (i) = 1N ∑N i α (i) 0 and then compare the average confidence change. The average confidence change is computed by taking the ratio of the average confidence of N corrupted data at severity s and the average confidence of N clean data (i.e. the corrupted data at severity 0) i.e. avg-confsavg-conf0 for s ∈ [[1, 5]]. NatPN maintains acompetitive accuracy (Fig. 3, left) while assigning higher epistemic uncertainty as desired (Fig. 3, right). Baselines provide a slower relative confidence decay.
Regression & Count Prediction. We show the results for the Bike Sharing, the tabular UCI datasets and the image NYU Depth v2 datasets in Tab. 4, 5, 6. For the large NYU dataset, we compare against all baselines which require only a single model to be trained. Overall, NatPN outperforms other single-pass models for 23/26 scores for regression, thus significantly improving calibration and OOD detection scores. Further, NatPN shows a strong improvement for calibration and OOD detection for count prediction with Poisson distributions among all models. Interestingly, all the models are less calibrated on the Bike Sharing dataset using a target Poisson distribution rather than a target Normal distribution. This suggests a mismatch of the Poisson distribution for this particular task. The almost perfect OODom scores of NatPN validate again Thm. 1 which also holds for regression.
Inference Speed. We show the average inference time per batch for all models on CIFAR-10 for classification and the NYU Depth v2 dataset for regression in Tab. 7. NatPN shows a significant improvement over Dropout and Ensemble which are both approximately five times slower since they require five forward passes for prediction. Notably, the NatPN speedup does not deteriorate target error and uncertainty scores. NatPN is slightly slower than RPriorNet, EnD2 and EvReg as they do not evaluate an additional normalizing flow. However, NatPN – which uses a single normalizing flow – is faster than
PostNet – which scales linearly w.r.t. the number of classes since it evaluates one normalizing flow per class. Lastly, NatPN is the only single-pass model that can be used for both tasks.

heading: 5 CONCLUSION
text: We introduce Natural Posterior Network which belongs to the family of models parametrizing conjugate prior distributions. NatPN is capable of efficient uncertainty estimation for any task where the target distribution is in the exponential family (incl. classification, regression and count prediction). NatPN relies on the Bayes formula and the general form of exponential family distributions to perform a closed-form input-dependent posterior update over the target distribution. Further, an ensemble of NatPNs has a principled Bayesian combination interpretation. Theoretically, NatPN guarantees high uncertainty far from training data. Experimentally, NatPN achieves fast, versatile and high-quality uncertainty predictions with strong performance in calibration and OOD detection.

heading: 6 ETHICS STATEMENT
text: Accurate uncertainty estimation aims at improving trust in safety-critical domains subject to automation, and in a maintenance context where the underlying data distribution might slowly shift over time. In this regard, NatPN significantly improves the applicability of uncertainty estimation across a wide range of prediction domains (e.g. classification, regression, count prediction, etc) while maintaining a fast inference time. This could be particularly beneficial in industrial applications with time pressure and potential critical consequences (e.g. finance, medicine, policy decision making, etc).
Nonetheless, while NatPN achieves high-quality uncertainty estimation, there is always a risk that NatPN does not fully capture the real-world complexity e.g. for OOD data close to ID data. Furthermore, we raise awareness about two other risks of excessive trust related to the Dunning-Kruger effect (Kruger & Dunning, 2000): human excessive trust in Machine Learning model capacity, and human excessive trust in its own interpretation capacity. Therefore, we encourage practitioners to proactively confront the model design and its uncertainty estimates to desired behaviors in real-world use cases.

heading: 7 REPRODUCIBILITY STATEMENT
text: We provide all datasets at the following anonymous link 1. In App. F, we give a detailed description for each dataset used in this paper. This description includes the task description, the dataset size, the input/output dimensions, the input/output preprossessing and the train/validation/test splits used in the experiments. We provide the model code at the following anonymous link 2. In App. G, we give a detailed description for the architecture and grid search performed for each model used in this paper. Specifically, we provide an hyper-parameter study for NatPN in App. I.6, In App. H, we give a detailed description of the metrics used in the experiments. Finally, we provide a complete proof of Thm. 1, a detailed description of the Bayesian loss and relevant formulae for exponential family distributions in App. A, App. B and App. C.

heading: A THEOREM 1
text: We prove theorem 1 based on Lemmas 2 and 3. Lemma 2 states that the input space can be divided in a finite number of linear regions (Arora et al., 2018). Lemma 3 states that a probability density with bounded derivatives has to converge to 0 at infinity (Dix, 2013). We additionally recall Lemma 4 which provide a similar convergence guarantee without the bounded derivative constraint (Niculescu & Popovici, 2011). Finally, Lemma 5 particularly shows that the guarantee of theorem 1 can be obtained with Gaussian Mixtures which are commonly used for density estimation or radial flows which are used in the experiments. Lemma 2. (Arora et al., 2018) Let {Ql}Rl be the set of linear regions associated to the piecewise ReLU network fφ(x). For any x ∈ RD, there exists δ∗ ∈ R+ and l∗ ∈ 1, ..., R such that δx ∈ Ql∗ for all δ > δ∗.
Lemma 3. (Dix, 2013) Let p ∈ L1(0,∞) with bounded first derivative p′, then p(δ) → δ→∞ 0. This convergence is stronger than in Lem. 4 as the limit is not in density but with standard limit notation.
Lemma 4. (Niculescu & Popovici, 2011) Let p ∈ L1(0,∞), then p(δ) → δ→∞ 0 in density. This means that the sets where p(t) is far from its 0 limit (i.e. {t ≥ 0 : |p(t)| ≥ } with > 0) has zero density. Lemma 5. Let P(z |ω) be parametrized with a Gaussian Mixture Model (GMM) or a radial flow, then P(z |ω) →
||z||→∞ 0.
Proof. We prove now lem. 5 for GMM and radial flow. The proof is straightforward for the GMM parametrization since every Gaussian component of the mixture has 0 limit when ||z|| → ∞. Let denote now p1(z) = P(z |ω) be parametrized with a radial flow transformation g(z) and a base unit Gaussian distribution p0 i.e.:
p1(z) = p0(g(z))× |det ∂g(z)
∂z |
Further, we can express the transformation g(z) and its determinant det∂g(z)∂z as follows:
g(z) = z + βh(α, r)(z − z0)
det ∂g(z)
∂z =
1 + βh(α, r) + βh′(α, r)r
(1 + βh(α, r))H−1
where h(α, r) = 1α+r and r = ||z − z0||. On one hand, we have ||g(z)|| → +∞ when ||z|| → ∞ since ||βh(α, r)(z−z0)|| < β. Thus, the base Gaussian density p0(g(z))→ 0 when ||z|| → ∞. On the other hand, we have |det∂g(z)∂z | → 1 since βh(α, r)→ 0 and βh
′(α, r)r → 0 when ||z|| → ∞. Therefore, the transformed density p0(g(z))×|det∂g(z)∂z | → 0 when ||z|| → ∞ which ends the proof. Note that this proof can be extended to stacked radial flows by induction.
Theorem. Let a NatPN model parametrized with a (deep) encoder fφ with piecewise ReLU activations, a decoder gψ and the density P(z |ω). Let fφ(x) = V (l)x + a(l) be the piecewise affine representation of the ReLU network fφ on the finite number of affine regions Q(l) (Arora et al., 2018). Suppose that V (l) have independent rows and the density function P(z |ω) has bounded derivatives, then for almost any x we have P(fφ(δ · x) |ω) →
δ→∞ 0. i.e the evidence becomes small far from
training data.
Proof. We prove now thm. 1. Let x ∈ RD be a non-zero input and fφ be a ReLU network. Lem. 2 implies that there exists δ∗ ∈ R+ and l ∈ {1, ..., R} such that δ · x ∈ Q(l) for all δ > δ∗. Thus, zδ = fφ(δ · x) = δ · (V (l)x) + a(l) for all δ > δ∗. Note that for δ ∈ [δ∗,+∞], zδ follows an affine half line Sx = {z | z = δ · (V (l)x) + a(l), δ > δ∗} in the latent space. Further, note that V (l)x 6= 0 and ||zδ|| →
δ→∞ +∞ since x 6= 0 and V (l) has independent rows.
We now define the function p(δ) = P(zδ |ω) which is the density function P(z |ω) restricted on the affine half line Sx. Since P(z |ω) is a normalized probability density, then the function δ 7→ p(δ−δ∗)
is integrable on [0,+∞]. Indeed we have:∫ +∞ 0 p(δ − δ∗)dδ = ∫ +∞ δ∗ p(δ)dδ
= ∫ +∞ δ∗ P(δ · (V (l)x) + a(l) |ω)dδ
= ∫ Sx P(z |ω)dz < +∞
Further since the function P(z |ω) has bounded derivatives, we can apply Lem. 3 to the function δ 7→ p(δ − δ∗) to get the expected result i.e.
P(fφ(δ · x) |ω) = p(δ) = p((δ + δ∗)− δ∗) → δ→∞ 0
which ends the proof.
Alternatively a slightly weaker conclusion also holds if the density function does not have bounded derivatives using lem. 4 (instead of lem. 3) with the notion of limit in density. The stronger conclusion is valid if we parametrize P(z |ω) with a Gaussian Mixture Model or a radial flow density according to lem. 5 since ||zδ|| →
δ→∞ +∞.
Further, we provide additional comments on the assumption that a trained network converges to linear transformation with exactly two or more dependent rows in Thm. 1. Under this realistic condition Hein et al. (2019), the null space is reduced to 0 according to the rank-nullity theorem meaning that there should be no dead input feature/pixel. If this condition does not hold, this would mean that this specific input feature/pixel is not informative for the prediction task. Thus it could be desired in practice that it does not affect the uncertainty on the prediction. This latter aspect is discussed in the “Task-Specific OOD” paragraph in Sec. 3.6.

heading: B BAYESIAN LOSS
text: NatPN minimizes the following Bayesian formulation: L(i) = −Eθ(i)∼Qpost,(i) [logP(y(i) |θ(i))]︸ ︷︷ ︸
(i)
−H[Qpost,(i)]︸ ︷︷ ︸ (ii)
(7)
where H[Qpost,(i)] denotes the entropy of the predicted posterior distribution Qpost,(i). This loss is generally not equal to the ELBO loss. While the term (i) can be viewed as an ELBO loss without KL regularization, the term (ii) is not necessarily equal to the prior KL regularization term in the ELBO loss since a proper uniform prior might not exist (e.g. the target y is a real number). Indeed, if the target y is a real number, there exists no uniform prior on θ and the Bayesian loss and ELBO loss are different i.e. KL(Q ||Qprior) = ∫ Q(θ) log( Q(θ)Qprior(θ) )dθ 6= ∫ Q(θ) logQ(θ)dθ = H(Q). Nonetheless, when a uniform prior Qunif exists (e.g. the target y is a class), the loss optimization can be seen as an amortized variational optimization of an ELBO loss (Zhang et al., 2018) i.e. L(i) = −EQpost,(i) [logP(y(i) |θ(i))] + KL[Q
post,(i) ‖Qunif] where the predicted distribution Qpost,(i) is the variational distribution — which approximates the true posterior distribution. Indeed, the KL regularization term is equal to the entropy regularization term i.e. KL(Q ||Qunif) =∫ Q(θ) log( Q(θ)Qunif(θ)dθ) ∝ ∫ Q(θ) logQ(θ)dθ) = H(Q). Hence, the loss name “Bayesian loss” (Charpentier et al., 2020) is motivated by its difference with the ELBO loss and its Bayesian property at optimum.

heading: C FORMULAE FOR EXPONENTIAL FAMILY DISTRIBUTIONS

heading: C.1 GENERAL CASE
text: Target Distribution. An exponential family distribution on a target variable y ∈ R with natural parameters θ ∈ RL can be denoted as
P(y |θ) = h(y) exp ( θTu(y)−A(θ) ) (8)
where h : R→ R is the carrier measure, A : RL → R the log-normalizer and u : R→ RL the sufficient statistics.
Conjugate Prior Distribution. An exponential family distribution P always admits a conjugate prior: Q(θ |χ, n) = η(χ, n) exp ( nθTχ− nA(θ) ) (9)
where η : RL×R→ R is a normalization factor and A the log-normalizer of the distribution P as in Eq. 8). Posterior Predictive Distribution. The posterior predictive distribution is given as∫ P(y(i)|θ)Q(θ|χpost,(i), npost,(i))dθ where the parameter θ is marginalized out (Gal, 2016). This distribution can always be computed in closed form for exponential family distributions:
P(y |χ, n) = h(y) η(χ, n) η ( nχ+u(y) n+1 , n+ 1 ) (10) where h is the carrier measure defined in Eq. 8 and η is the normalization factor defined in Eq. 9. In particular, the posterior predictive distributions for Categorical, Normal and Poisson target distributions are Categorical, Student and Negative Binomial distributions, respectively.
Likelihood. The log-likelihood of an exponential family distribution can be written as follows:
logP(y(i) |θ) = log h(y(i)) + θTu(y(i))−A(θ) (11)
Expected Log-Likelihood. Given the log-likelihood of an exponential family distribution, its expectation under the conjugate prior distribution Q(θ|χ, n) can be written as
Eθ∼Q(χ,n)[logP(y(i) |θ)] = log h(y(i)) + Eθ∼Q(χ,n)[θ]Tu(y(i))− Eθ∼Q(χ,n)[A(θ)] (12) where EQ(θ|χ,n)[θ] = χ (Brown, 1986; Diaconis & Ylvisaker, 1979).
Entropy. The entropy of a random variable y ∼ P(y|θ) for an exponential family distribution P can be written as follows (Nielsen & Nock, 2010):
H[P(y|θ)] = A(θ)− θT∇θA(θ)− Ey∼P(θ)[log h(y)] (13)

heading: C.2 CATEGORICAL & DIRICHLET DISTRIBUTIONS
text: The Dirichlet distribution p ∼ Dir(α) is the conjugate prior of the categorical distributions y ∼ Cat(p).
Target Distribution. The density and the entropy of the categorical distribution are:
Cat(y |p) = K∑ i=1 I[yi = 1] pi (14)
H[Cat(p)] = C∑ c=1 log pc (15)
Conjugate Prior Distribution. The density and the entropy of the Dirichlet distribution are: Dir(p |α) = Γ (∑C c=1 αc ) ∏K c=1 Γ(αc) C∏ c=1 pαc−1c (16)
H[Dir(α)] = logB(α) + (α0 − C)ψ(α0)− ∑ c (αc − 1)ψ(αc) (17)
where ψ(α) and B(α) denote Digamma and Beta functions, respectively, and α0 = ∑ c αc.
Expected Log-Likelihood. The expected likelihood of the categorical distribution Cat(p) under the Dirichlet distribution Dir(α) is
Ep∼Dir(α)[log Cat(y |p)] = ψ(αy)− ψ(α0) (18) where ψ(α) denotes Digamma function.

heading: C.3 NORMAL & NORMAL-INVERSE-GAMMA DISTRIBUTIONS
text: The Normal-Inverse-Gamma (NIG) distribution µ, σ ∼ NΓ-1(µ0, λ, α, β) is the conjugate prior of the normal distribution y ∼ N (µ, σ). Note that as both parameters λ and α can be viewed as pseudocounts. However, the natural prior parametrization enforces a single pseudo-count n corresponding to λ = 2α.
Target Distribution. The density and the entropy of the Normal distribution are:
N (y |µ, σ) = 1 σ √ 2π exp
( − (x− µ) 2
2σ2
) (19)
H[N (µ, σ)] = 1 2 log(2πσ2) (20)
Conjugate Prior Distribution. The density and the entropy of the NIG distribution are:
NΓ-1(µ, σ |µ0, λ, α, β) = βα √ λ
Γ(α) √ 2πσ2
( 1
σ2
)α+1 exp ( −2β + λ(µ− µ0) 2
2σ2
) (21)
H[NΓ-1(µ0, λ, α, β)] = 1
2 + log
( (2π) 1 2 β 3 2 Γ(α) ) − 1
2 log λ+ α−
( α+ 3
2
) ψ(α) (22)
where Γ(α) denotes the Gamma function.
Expected Log-Likelihood. The expected likelihood of the Normal distribution N (µ, σ) under the NIG distribution NΓ-1(µ0, λ, α, β) is:
E(µ,σ)∼NΓ-1(µ,λ,α,β)[logN (y |µ, σ)] (23) = E [ − (y − µ) 2
2σ2 − log(σ
√ 2π) ] (24)
= 1
2
( −E [ (y − µ0)2
2σ2
] − E [ log σ2 ] − log 2π ) (25)
= 1
2
( −y2 E [ 1
σ2
] + 2y E [ µ σ2 ] − E [ µ2 σ2 ] + E [ log 1 σ2 ] − log 2π ) (26)
= 1
2 ( −α β (y − µ0)2 − 1 λ + ψ(α)− log β − log 2π ) (27)
where ψ(α) denotes the Digamma function. We used here the moments of the NIG distribution E [ µ σ2 ] = αµ0β , E [ 1 σ2 ] = αβ , E [ µ2 σ2 ] = αµ20 β + 1 λ , and the moment of the inverse Gamma distribution
E [ log 1σ2 ] = ψ(α)− log β.

heading: C.4 POISSON & GAMMA DISTRIBUTIONS
text: The Gamma distribution λ ∼ Γ(α, β) is the conjugate prior of the Poisson distributions y ∼ Poi(λ). Target Distribution. The density and the entropy of the Poisson distribution are:
Poi(y |λ) = λ y exp(−λ)
y! (28)
H[Poi(λ)] = λ(1− log(λ))) + exp(−λ) ∞∑ k=0 λk log(k!) k! (29)
Conjugate Prior Distribution. The density and the entropy of the Gamma distribution are:
Γ(λ |α, β) = β α
Γ(α) λα−1 exp(−βλ) (30)
H[Γ(α, β)] = α+ log Γ(α)− log β + (1− α)ψ(α) (31)
where Γ(α) denotes the Gamma function.
Expected Log-Likelihood. The expected likelihood of the Poisson distribution Poi(λ) under the Gamma distribution Γ(α, β) is
Eλ∼Γ(α,β)[log Poi(y |λ)] = E[log λ]y − E[λ]− y∑ k=1 log k (32)
= (ψ(α)− log β)y − α β − y∑ k=1 log k (33)
where ψ(α) denotes Digamma function. We used here the moments the Gamma distributions E[log λ] = ψ(α)− log β and E[λ] = αβ . Note that ∑y k=1 log k is constant w.r.t. parameters α, β.

heading: D APPROXIMATION OF ENTROPIES
text: The computation of a distribution’s entropy often requires subtracting huge numbers from each other. While these numbers tend to be very close together, this introduces numerical challenges. For large parameter values, we therefore approximate the entropy by substituting numerically unstable terms and simplifying the resulting formula. For this procedure, we make use of the following equivalences (taken from Rocktäschel (1922) and Whittaker & Watson (1927), respectively):
log Γ(x) ≈ 1 2
log 2π − x+ ( x− 1
2
) log x (34)
ψ(x) = log x− 1 2x
+O ( 1
x2
) (35)
We note that Eq. 35 especially implies ψ(x) ≈ log x and xψ(x) ≈ x log x− 12 for large x.

heading: D.1 DIRICHLET DISTRIBUTION
text: We consider a Dirichlet distribution Dir(α) of order K with α0 = ∑K i=1 αi. For α0 ≥ 104, we use the following approximation:
H [Dir(α)] ≈ K − 1 2 (1 + log 2π) + 1 2 K∑ i=1 logαi − ( K − 1 2 ) log K∑ i=1 αi (36)

heading: D.2 NORMAL-INVERSE-GAMMA DISTRIBUTION
text: We consider a Normal-Inverse-Gamma distribution NΓ-1(µ, λ, α, β). For α ≥ 104, we use the following approximation:
H [ NΓ-1(µ, λ, α, β) ] ≈ 1 + log 2π − 2 logα+ 3
2 log β − 1 2 log λ (37)

heading: D.3 GAMMA DISTRIBUTION
text: We consider a Gamma distribution Γ(α, β). For α ≥ 104, we use the following approximation:
H [Γ(α, β)] ≈ 1 2 + 1 2 log 2π + 1 2 logα− log β (38)

heading: E FORMULAE FOR UNCERTAINTY ESTIMATES
text: Aleatoric Uncertainty. The entropy of the target distribution P(y|θ) was used to estimate the aleatoric uncertainty i.e. H[P(y|θ)].
Epistemic Uncertainty. The evidence parameter npost,(i) was used to estimate the epistemic uncertainty. Due to its interpretation as a pseudo-count of observed labels, the posterior evidence parameter is indeed a natural indicator for the epistemic uncertainty.
Predictive Uncertainty. The entropy of the posterior distribution Q(θ|χpost,(i), npost,(i)) was used to estimate the predictive uncertainty.

heading: F DATASET DETAILS
text: We use a train/validation/test split in all experiments. For datasets with a dedicated test split, we split the rest of the data into training and validation sets of size 80%/20%. For all other datasets, we used 70%/15%/15% for the train/validation/test sets. All inputs are rescaled with zero mean and unit variance. Similarly, we also scale the output target for regression. We provide the datasets at the following anonymous link 3.
Sensorless Drive (Dua & Graff, 2017) This is a tabular dataset where the goal is to classify extracted motor current measurements into 11 different classes. We remove the last two classes (9 and 10) from training and use them as the OOD dataset for OOD detection experiments. Each input is composed of 48 attributes describing motor behavior. The dataset contains 58, 509 samples in total.
MNIST (LeCun et al., 2010) This is an image dataset where the goal is to classify pictures of handdrawn digits into 10 classes (from digit 0 to digit 9). Each input is composed of a 1× 28× 28 tensor. The dataset contains 70, 000 samples. For OOD detection experiments, we use KMNIST (Clanuwat et al., 2018) and Fashion-MNIST (Xiao et al., 2017) containing images of Japanese characters and images of clothes, respectively. It uses the MIT License (MIT).
CIFAR-10 (Krizhevsky et al., 2009) This is an image dataset where the goal is to classify a picture of objects into 10 classes (airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck). Each input is a 3× 32× 32 tensor. The dataset contains 60, 000 samples. For OOD detection experiments, we use street view house numbers (SVHN) (Netzer et al., 2011) containing images of numbers and CelebA (Liu et al., 2015) containing images of celebrity faces. We do not use CIFAR100 (Krizhevsky et al., 2009) or TinyImageNet (Fei-Fei Li & Johnson, 2017) as OOD as they also contain images of vehicles and animals similar to CIFAR10. This rightly questions to what extent are these datasets really OOD for CIFAR10. Furthermore, we generate the corrupted CIFAR-10 dataset (Hendrycks & Dietterich, 2019) with 15 corruption types per image, each with 5 different severities. It uses the MIT License (MIT).
Bike Sharing (Fanaee-T & Gama, 2014) This is a tabular dataset where the goal is to predict the total number of rentals within an hour. Each input is composed of 15 attributes. We removed features related to the year period (i.e. record index, date, season, months) which would make OOD detection trivial, leading to 11 attributes. The dataset contains 17, 389 samples in total. For OOD detection, we removed the attribute season from the input data and only trained on the summer season. The samples related to winter, spring and autumn were used as OOD datasets.
Concrete (Dua & Graff, 2017) This is a tabular dataset where the goal is to predict the compressive strength of high-performance concrete. Each input is composed of 8 attributes. The dataset contains 1, 030 samples in total. For OOD detection, we use the Energy and Kin8nm datasets which have the same input size.
Kin8nm (Dua & Graff, 2017) This is a tabular dataset where the goal is to predict the forward kinematics of an 8-link robot arm. Each input is composed of 8 attributes. The dataset contains 8, 192 samples in total. For OOD detection, we the Concrete and Energy datasets which have the same input size.
NYU Depth v2 (Nathan Silberman & Fergus, 2012) This is an image dataset where the goal is to predict the depth of room images at each pixel position. All inputs are of shape 3x640x480 tensors while we rescale outputs to be 320x240 tensors at both training and test time. This setting is slightly different from Kendall & Gal (2017) and Nathan Silberman & Fergus (2012). Indeed, (Kendall & Gal, 2017) up-scales the model output to 640x480 at training and test time while (Nathan Silberman & Fergus, 2012) up-scales the model output to 640x480 at test time only. The dataset contains 50, 000 samples in total available on the DenseDepth GitHub 4. For OOD detection, we use the KITTI (Geiger
3https://natural-posterior-network.s3.eu-central-1.amazonaws.com/data. zip
4https://github.com/ialhashim/DenseDepth
et al., 2013) dataset containing images of driving cars and two out of the 20 categories from the LSUN (Yu et al., 2015) dataset.

heading: G MODEL DETAILS
text: We train all models using 5 seeds except for the large NYU dataset where we use a single randomly selected seed. All models are optimized with the Adam optimizer without further learning rate scheduling. We perform early stopping by checking loss improvement every epoch and a patience p selected per dataset (Sensorless Drive: p = 15, MNIST: p = 15, CIFAR10: p = 20, Bike Sharing: p = 50, Concrete: p = 50, Kin8nm: p = 30, NYU Depth v2: p = 2). We train all models on a single GPU (NVIDIA GTX 1080 Ti or NVIDIA GTX 2080 Ti, 11 GB memory). All models are trained after a grid search for the learning rate in [1e−2, 5e−4]. The backbone architecture is shared across models and selected per dataset to match the task needs (Sensorless Drive: 3 lin. layers with 64 hidden dim, MNIST: 6 conv. layers with 32/32/32/64/64/64 filters + 3 lin. layers with hidden dim 1024/128/64, CIFAR10: 8 conv. layers with 32/32/32/64/64/128/128/128 filters + 3 lin. layers with hidden dim 1024/128/64, Bike Sharing: 3 lin. layers with 16/16/16 hidden dim, Concrete: 2 lin. layers with 16/16 hidden dim, Kin8nm: 2 lin. layers with 16/16 hidden dim, NYU Depth v2: DenseDepth + 4 upsampling layers with convolutions and skip connections). For the NYU Depth v2 dataset, we use a pretrained DenseNet for initialization of the backbone architecture which was fine-tuned during training. The remaining layers are trained from scratch. All architectures use LeakyReLU activations. For further details, we provide the code at the following anonymous link 5.
Baselines. For the dropout models, we use the best drop out rate pdrop per dataset after a grid search in {0.1, 0.25, 0.4} and sample 5 times for uncertainty estimation. Similarly, we use m = 5 for the ensemble baseline and the distribution distillation. Note that Ovadia et al. (2019) found that a relative small ensemble size (e.g. m = 5) may indeed be sufficient in practice. We also train Prior Networks where we set βin = 1e2 as suggested in the original papers (Malinin & Gales, 2018; 2019). Prior Networks use Fashion-MNIST and SVHN as training OOD datasets for MNIST and CIFAR-10, respectively. As there is no available OOD dataset for the Sensorless Drive dataset, we use Gaussian noise as training OOD data.
Natural Posterior Network. We perform a grid search for the entropy regularizer λ in the range [1e−5, 0], for the latent dimension H in {4, 8, 16, 32}, for the certainty budget NH in {e 12H , eH , elog( √ 4π)H}, and for normalizing flow type between radial flows (Rezende & Mohamed, 2015) with 8, 16 layers and Masked Autoregressive flows (Germain et al., 2015; Papamakarios et al., 2017) with 4, 8, 16 layers. Further results on latent dimensions, density types, number of normalizing flow layers and certainty budget are presented in Sec. I.6. We use “warm-up” training for the normalizing flows for all datasets except for the simple Concrete and Kin8nm datasets, and the NYU Depth v2 dataset which starts from a pretrained encoder. We use “fine-tuning” for the normalizing flows for all datasets except for the simple Concrete and Kin8nm datasets. As prior parameters, we set χprior = 1C/C, nprior = C for classification, χprior = (0, 100)T , nprior = 1 for regression and χprior = 1, nprior = 1 for count prediction. Note that the mean of these prior distributions correspond to an equiprobable Categorical distribution Cat(1C/C), a Normal distribution with large variance N (0, 10) and a Poisson distribution with a unitary mean Poi(1). Those prior target distributions represent the safe default prediction when no evidence is predicted.

heading: H EXPERIMENT DETAILS
text: Target Error Metric. For classification, we use the standard accuracy 1N ∑ i I[y∗,(i) = y(i)] where y∗,(i) is the one-hot true label and y(i) is the one-hot predicted label. For regression, we use the
standard Root Mean Square Error √
1 N ∑N i (y ∗,(i) − y(i))2.
Calibration Metric. For classification, we use the Brier score which is computed as 1C ∑N i ||p(i) − y(i)||2 where p(i) is the predicted softmax probability and y(i) is the one-hot encoded ground-truth label. For regression and count prediction, we use the absolute difference between the percentile
5https://natural-posterior-network.s3.eu-central-1.amazonaws.com/code. tar.gz
p and the percentage of target lying in the confidence interval Ip = [0, p2 ] ∪ [1 − p 2 , 1] under the predicted target distribution. Formally, we compute ppred = 1N ∑ i I[Fθ(i)(y∗,(i))) ∈ Ip] where Fθ(i)(y ∗,(i)) = P(y ≤ y∗,(i) |θ(i)) is the cumulative function of the predicted target distribution evaluated at the true target. For example, the percentile p = 0.1 would be compared to ppred = 1 N ∑ i I[Fθ(i)(y∗,(i))) ∈ [0, 0.05]∪ [0.95, 1]] which should be close to 0.10 for calibrated predictions.
We compute a single calibration score by summing the square difference for p ∈ {0.1, . . . , 0.9} i.e.√∑ p(p− ppred)2 (Kuleshov et al., 2018).
OOD Metric. The OOD detection task can be evaluated as a binary classification. Hence, we assign class 1 to ID data and class 0 to OOD data task and use the aleatoric and epistemic uncertainty estimates as scores for OOD data. It enables to compute final scores using the area under the precision-recall curve (AUC-PR) and the area under the receiver operating characteristic curve (AUC-ROC). Both metrics have been scaled by 100. We obtain numbers in [0, 100] for all scores instead of [0, 1]. Results for AUC-ROC are reported in Sec. I.7. For the aleatoric uncertainty, we use the negative entropy of the predicted target distribution. For the epistemic uncertainty, we use the predicted evidence for models parametrizing conjugate-prior, or the variance of the predicted winning probability class for classification and the variance of the mean for regression and class count prediction for ensemble or dropout.
Inference Time Metric. We measure inference time of models in ms and used NVIDIA GTX 1080 Ti GPUs. We evaluate the inference for one classification dataset (CIFAR-10) and one regression dataset (NYU Depth v2). For evaluation, we use a randomly initialized model and simply push random data through the model with batch size of 4,096 CIFAR10 and batch size of 4 for NYU Depth v2. The final numbers are averaged over 100 batches excluding the first batch due to GPU initialization. Compared models shared the same backbone architecture.

heading: I ADDITIONAL EXPERIMENTS

heading: I.1 MNIST, FASHION MNIST, CIFAR10 AND BIKE SHARING RESULTS
text: Table 8: Results on MNIST (classification with Categorical target distribution). Best scores among all single-pass models are in bold. Best scores among all models are starred. Gray numbers indicate that R-PriorNet has seen samples from the FMNIST dataset during training.
Accuracy Brier K. Alea. K. Epist. F. Alea. F. Epist. OODom Alea. OODom Epist.
Dropout 99.45± 0.01 1.07± 0.05 98.27± 0.05 97.82± 0.08 *99.40± 0.03 98.01± 0.14 43.86± 1.62 74.09± 0.92 Ensemble 99.46± 0.02 1.02± 0.02 98.39± 0.07 98.43± 0.05 99.33± 0.06 98.73± 0.08 40.98± 1.80 66.54± 0.58 NatPE *99.55± 0.01 *0.84± 0.03 96.39± 0.73 *99.61± 0.02 97.49± 0.85 *99.70± 0.04 *100.00± 0.00 *100.00± 0.00
Accuracy Brier M. Alea. M. Epist. K. Alea. K. Epist. OODom Alea. OODom Epist.
Dropout 92.44± 0.17 13.89± 0.31 60.75± 1.41 75.85± 1.73 76.57± 1.30 92.48± 0.46 39.97± 0.69 90.90± 1.74 Ensemble 92.64± 0.10 13.63± 0.25 77.14± 1.49 90.78± 0.75 86.20± 0.76 95.16± 0.35 37.30± 0.83 82.93± 0.96 NatPE *92.89± 0.06 14.44± 0.06 82.56± 0.33 96.38± 0.29 92.12± 0.17 *98.79± 0.09 *100.00± 0.00 *100.00± 0.00
StandardNet 90.28± 0.24 17.12± 0.53 71.81± 2.43 – 82.28± 0.97 – 32.82± 0.73 – SNGP 91.38± 0.08 16.73± 0.46 89.40± 1.66 – 95.31± 0.42 – 100.00± 0.00 – R-PriorNet 91.53± 0.10 *12.21± 0.20 *98.83± 0.49 *99.54± 0.18 99.96± 0.02 99.99± 0.00 72.23± 6.32 48.84± 6.09 EnD2 91.84± 0.03 29.23± 0.79 79.32± 1.39 91.61± 1.04 91.99± 0.06 98.36± 0.20 43.70± 3.37 36.73± 3.74 PostNet 91.04± 0.10 16.11± 0.30 90.56± 1.25 92.10± 1.77 *96.65± 0.33 97.06± 0.42 *100.00± 0.00 *100.00± 0.00 NatPN 91.65± 0.14 14.88± 0.30 81.12± 2.77 96.51± 0.81 93.03± 1.00 98.38± 0.23 99.99± 0.01 *100.00± 0.00

heading: I.2 UNCERTAINTY VISUALIZATION ON TOY DATASETS
text: We visualize the aleatoric and the epistemic uncertainty for two toy datasets with three classes with the same number of training examples for the three classes (see Fig. 4) and different number of training examples for the three classes (see Fig. 5). The predictions are more aleatorically certain close to training samples. The preidctions are more epistemically uncertain close to fewer training examples and very epistemically uncertain for region far from all training data.

heading: I.3 LATENT SPACE VISUALIZATIONS
text: We propose additional visualizations of the latent space for MNIST with t-SNE (Chan et al., 2019) with different perplexities (see Fig. 6). For all perplexities, we clearly observe ten green clusters corresponding to the ten classes for MNIST. The KNMIST (OOD) samples in red can easily be separated from the MNIST (ID) samples in green. As desired, NatPN assigns higher log-probabilities used in evidence computation to ID samples from MNIST.

heading: I.4 HISTOGRAM OF UNCERTAINTY ESTIMATES
text: We visualize the histogram distribution of the entropy of the posterior distribution accounting for predictive uncertainty for ID (MNIST/NYU) and OOD (KNMIST and Fashion-MNIST/LSUN classroom and LSUN church + KITTI) (see Fig. 7). We clearly observe lower predictive entropy for ID data than for OOD data for both MNIST and NYU datasets. On one hand, the entropy clearly differentiates between ID data (MNIST) and any other OOD datasets (KMNIST, Fashion MNIST, OODom) for classification. We intuitively explain this clear distinction since the samples from the OOD datasets are irrelevant for the digit classification task. On the other hand, the entropy is still a good indicator of ID (NYU) and OOD datasets (LSUN classroom and LSUN church + KITTI) for regression although the distinction between ID and OOD datasets is less strong compared to MNIST. We intuitively explain this behavior since the task of depth estimation is still relevant to LSUN classroom and LSUN church + KITTI.

heading: I.5 UNCERTAINTY VISUALIZATION ON NYU DEPTH V2 DATASET
text: We visualize the prediction and the predictive uncertainty per pixel for the NYU Depth v2 dataset (see Fig. 8). We observe accurate target predictions compared to the ground truth depth of the images. Further NatPN assigns higher uncertainty for pixels close to object edges, which is reasonable since the depth abruptly change at these locations.

heading: I.6 HYPER-PARAMETER STUDY
text: As a ablation study, we also report the results of the grid search on the latent dimension, normalizing flow types and number of normalizing flow layers for MNIST, CIFAR-10 and Bike Sharing datasets in Tab. 12, 13, 14, 15. While most models converge to fairly good uncertainty estimates, we notice that 16 layers of simple radial flows on latent spaces of 16 dimensions were achieving very good results in practice.
Changing the flow type or the number of normalizing flow layers does not lead to strong variations of the results except for Bike sharing with Poisson target distributions. In this case, more complex MAF normalizing flows improve NatPN performance.
The latent dimension appears to be a more important choice for the model convergence. As an example, a higher latent dimension of 16 or 32 leads to significantly better performances than a latent dimension of 4 on MNIST, CIFAR10 and Bike Sharing datasets. We hypothesize that too low latent dimensions are less able to encode the necessary information for the prediction task, leading to worse target errors.
Further, we compare three different variants of the certainty budget NH used in the evidence computation n(i) = NH P(z(i) |ω): a constant unit budget (i.e. NH = 1 (I)) corresponding to a fixed budget regardless of the number of training data and the latent dimension, a budget equals to the number of training data (i.e. NH = N (II)) similarly to Charpentier et al. (2020), or a budget which scales exponentially with the number of latent dimensions (e.g. NH equal to e 1 2H (III), eH (IV) or elog( √
4π)H (V)). We observe that scaling the budget w.r.t. the latent space dimension (H-budget) is more stable in practice than constant budget (1-budget) and budget related to the number of training data (N -budget) (see. Tab. 12,13,14,15). In aprticular, the H-budgets achieve more better results on
higher latent dimensions and performance on par with the other certainty budget scheme otherwise. The intuition is that due to the curse of dimensionality, the expected value of a probability density function Ez[P(z)] tends to decrease exponentially fast. For example, we have Ez[P(z)] = 1(√4π)H when z ∼ N (0,1) in a H-dimensional space. Increasing the certainty budget NH exponentially w.r.t. to the dimension H avoids numerical issues by allocating close to 0 evidence to latent representations. In our experiments, we use a grid search in different exponential scaling NH equal to e 1 2H (III), eH (IV), elog( √ 4π)H (V).

heading: I.7 OOD DETECTION WITH AUC-ROC SCORES
text: In addition to the AUC-APR scores, we report the OOD detection results for MNIST, CIFAR10 and Bike Sharing datasets in Tab. 16, 17, 18 with AUC-ROC scores. Similarly as with AUC-APR scores, NatPN and NatPE achieve very competitive performances compare to the baselines. It particular, they outperform all baselines to detect challenging OODom data.

Review summaries:
The authors propose NatPN, a model which can estimate predictive uncertainty for classification and regression tasks. NatPN predicts the parameters of the posterior distribution which belongs to the exponential family. Contrary to other algorithms, NatPN requires no OOD data for training, and is able to evaluate the uncertainty in a single forward pass utilizing normalizing flows for density estimation.

This paper proposes Natural Posterior Networks (NatPNs), a technique to provide uncertainty-estimation to tasks where the likelihood is an exponential family, e.g. classification or regression. NatPNs leverage the properties of exponential families, i.e. conjugacy and closed-form posterior predictive for fast and elegant Bayesian Inference. This is combined with a Bayesian treatment of the loss function that allows for end-to-end training. Furthermore, it uses a normalizing flow to account for the epistemic uncertainty. The normalizing flow density is supposed to increase the evidence on the training data and thereby decrease it everywhere else. The posterior distribution is on the outputs not on the weights of the NN which makes it easier to train. The paper provides one theorem for why the posterior uncertainty is meaningful and multiple experiments showing practical improvements for multiple exponential families and datasets.    NatPNs are an extension of Posterior Networks. However, the differences are significant and well explained in the paper. From my perspective, the contributions are clearly novel enough to justify this new paper.  

The paper introduces a new method Natural Posterior Network (NatPN), an extension to the Posterior Network (Charpentier et al., 2020). NatPN aims to tackle the problem of enabling calibrated uncertainty estimates for in and out-of-distribution inputs for exponential family likelihoods parameterized by deep neural networks. In particular NatPN maps input samples into a latent space on which a normalizing flow is defined. A mapping from this latent space and its corresponding likelihood under the normalizing flow to the parameters of exponential family update rule is defined. The exponential family posterior tends towards the prior parameters for data points far from the training data and prior has little influence for data points within the training distribution.  NatPN makes two significant changes to the Posterior Network 1) it generalizes the method to the exponentially family, allowing for regression and counting tasks beyond just classification as per the Posterior Network and 2) it uses a single normalizing flow rather than class specific normalizing flows as per the Posterior Network, in theory this aids the scalability of the method to datasets with many classes. In addition a minor change is made to the update rule of the posterior parameters.  The paper presents extensive empirical results on classification, regression and counting tasks across several relatively small scale datasets. NatPN is shown to perform on par or slightly better than similar methods from the literature.

This paper proposes a single-pass uncertainty estimation method for neural networks by predicting the update to the natural parameters of the conjugate prior to the likelihood of the data distribution and optimizing a corresponding ‘Bayesian loss’. In that it generalizes PostNet (Charpentier et al., 2020) beyond classification. The paper reports competitive or improved performance across a range of datasets and against both standard and recent baselines.