On Uncertainty, Tempering, and Data Augmentation in Bayesian Classiﬁcation
Abstract
Aleatoric uncertainty captures the inherent randomness of the data, such as measurement noise.
In Bayesian regression, we often use a Gaussian observation model, where we control the level of aleatoric uncertainty with a noise variance parameter.
By contrast, for Bayesian classiﬁcation we use a categorical distribution with no mechanism to represent our beliefs about aleatoric uncertainty.
Our work shows that explicitly accounting for aleatoric uncertainty signiﬁcantly improves the performance of Bayesian neural networks.
We note that many standard benchmarks, such as CIFAR- 10 , have essentially no aleatoric uncertainty.
Moreover, we show that data augmentation in approximate inference softens the likelihood, leading to underconﬁdence and misrepresenting our beliefs about aleatoric uncertainty.
Accordingly, we ﬁnd that a cold posterior, tempered by a power greater than one, often more honestly reﬂects our beliefs about aleatoric uncertainty than no tempering — providing an explicit link between data augmentation and cold posteriors.
We further show that we can match or exceed the performance of posterior tempering by using a Dirichlet observation model, where we explicitly control the level of aleatoric uncertainty, without any need for tempering.
Introduction
Uncertainty is often compartmentalized into epistemic and aleatoric uncertainty [27, 33, 41].
Epistemic uncertainty, sometimes called model uncertainty, is the reducible uncertainty about which solution is correct given limited information.
Bayesian methods naturally represent epistemic uncertainty through a distribution over model parameters, leading to a posterior distribution over functions that are consistent with data.
As we observe more data, this posterior concentrates around a single solution.
Aleatoric uncertainty is the irreducible uncertainty in data, often representing measurement noise in regression or mislabeled training points in classiﬁcation [e.g. 4].
Although measurement noise can be reduced, for example, with better instrumentation, it is often a ﬁxed property of the data we are given.
Correctly expressing our assumptions about aleatoric uncertainty is crucial for achieving good predictive performance, both with Bayesian and non-Bayesian models [56].
In particular, our assumptions about aleatoric uncertainty profoundly affect predictive accuracy , not only predictive uncertainty.
In Figure 1(a,b) we show the predictive distributions of two Gaussian process (GP) regression models [54] trained on the same data and using the same RBF kernel function.
The only difference between these models is their assumptions about the aleatoric uncertainty.
The model in Figure 1(a) assumes a high observation noise (each point is corrupted by N (0 ,  2 ) , [Figure] with  2 = 1 ).
Consequently, this model explains many of the observations with noise — such that the predictive mean does not closely ﬁt the training datapoints.
The model in Figure 1(b) assumes a low observation noise (  2 = 10  2 ), and consequently the predictive mean runs through the training data, leading to very different predictions compared to the model in Figure 1(a).
Our assumptions about the aleatoric uncertainty are just as important in classiﬁcation.
We illustrate this point in Figure 1(c), where we ﬁx a dataset and consider two possible scenarios.
Scenario A : suppose we know that the data contains label noise, with some incorrectly labeled training examples.
In this case, it is reasonable to believe that the data points shown in red in Figure 1(c) are highly likely to be incorrectly labeled, and we should opt for a solution with a decision boundary shown with a dotted red line.
Scenario B : now, suppose that we know that the data are correctly labeled.
In this case, we want our model to perfectly classify all the training data and would prefer a solution shown by the dashed blue line.
Both of these solutions are reasonable descriptions of the data, and we can only make an informed choice between them by incorporating our assumptions about the aleatoric uncertainty.
While in regression problems we can easily express our assumptions about aleatoric uncertainty, such as through a noise variance parameter in a Gaussian likelihood, in classiﬁcation we do not have a direct way to express these beliefs.
Indeed, in practice we might use the same
Bayesian neural network (BNN) with the same likelihood and prior in both scenarios A and B above, necessarily leading to poor performance in at least one of these scenarios.
In this paper, we explicitly characterize aleatoric uncertainty in BNN classiﬁcation.
We show that cold posteriors [61] more honestly reﬂect our beliefs about aleatoric uncertainty than standard
Bayesian posteriors.
Further building on our analysis of aleatoric uncertainty in Bayesian classiﬁcation, we describe an alternative to cold posteriors called the noisy Dirichlet model .
The noisy Dirichlet model can be viewed as simply modifying the prior over the parameters of a BNN to put more mass on the solutions that make highly conﬁdent predictions on the training data, but only in scenarios with low aleatoric uncertainty. Unlike standard BNN classiﬁers, we get control over the aleatoric uncertainty through the prior.
This approach achieves competitive performance on image classiﬁcation problems with a valid Bayesian model and removes the cold posterior effect .
Finally, we show theoretically how data augmentation counterintuitively softens the likelihood, leading to solutions that underﬁt the training data.
These results precisely characterize the empirical link between data augmentation and the success of cold posteriors observed by Izmailov et al.
[31] and Fortuin et al.
[14], and show that cold posteriors in fact serve to correct for the effects of data augmentation on aleatoric uncertainty.
Related Work
Early work on Bayesian neural networks focused on hyperparameter learning and mitigating overﬁtting, using Laplace approximations, variational methods, and MCMC [e.g. 37, 25, 47].
More recently, Wilson and Izmailov [62] show how Bayesian model averaging is especially compelling for modern deep neural networks.
A number of recent works have focused on making Bayesian deep learning practical
[e.g., 63, 38, 49, 65, 12, 11], with improved performance, and essentially no overhead.
Modeling label noise.
In the context of label noise for classiﬁcation, prior works focus on modifying the loss function.
For example, Collier et al.
[9, 10] propose input-dependent noise losses for label noise in classiﬁcation to improve accuracy, but do not focus on the uncertainty estimates.
Similarly, Zhang and Sabuncu [66] and Feng et al.
[13] propose modiﬁcations of the standard crossentropy loss to provide increased robustness to label noise, but do not focus on modeling the inherent uncertainty in label noise settings. Dirichlet-based uncertainty (DBU). Recent literature proposes neural networks where the output is a Dirichlet distribution, capturing both the epistemic and aleatoric uncertainty [41, 57, 40, 42, 7, 67, 46, 59, 58, 34]. These models are generally proposed as efﬁcient alternatives to ensembles and Bayesian models, and targeted for improved uncertainty quantiﬁcation, anomaly detection and adversarial robustness.
Joo et al.
[32] reformulate the problem of minimizing the softmax crossentropy loss over the data into a collection of distribution matching problems.
In this paper, we study the Dirichlet distributions associated with the posterior over the predictive class probabilities, which arise naturally in standard Bayesian classiﬁcation models.
Contrary to the methods in the
DBU family, we do not modify the observation model or the structure of the network.
Cold posterior effect.
Wenzel et al.
[61] demonstrated with several examples that raising the posterior to a power 1 /T , with T < 1 , in conjunction with SGLD inference, improves performance over classical training, but T = 1 can provide worse results than classical training, in what has been termed the cold posterior effect .
However, in a study using HMC inference, Izmailov et al.
[31] showed that for all cases considered in Wenzel et al.
[61] there is no cold posterior effect when data augmentation is removed.
The sufﬁciency of data augmentation to observe the cold posterior effect has been conﬁrmed by several works using SG-MCMC inference [14, 48, 45].
Several works have suggested that misspeciﬁed priors explain cold posteriors, arguing that the current default choice of isotropic Gaussian priors in BNNs are inadequate [61, 64, 14].
However, Fortuin et al.
[14] ﬁnd that the cold posterior effect cannot be alleviated for convolutional neural networks by using heavy tailed or correlated priors under data augmentation.
With HMC inference and no data augmentation,
Izmailov et al.
[31] also show that standard Gaussian priors perform similarly to a range of other priors, such as heavy-tailed logistic or mixtures of Gaussian priors, and generally are high performing.
Noci et al.
[48] argue that many different factors — likelihoods, priors, data augmentation — can cause cold posteriors, and that there may be no one cause in general.
Aitchison [2] argue that BNN likelihoods are misspeciﬁed since many benchmark datasets have been carefully curated by human labelers.
They also show that posterior tempering is less helpful in the presence of label noise.
Adlam et al.
[1] also consider model misspeciﬁcation, showing a cold posterior effect can arise even with exact inference in GP regression when the aleatoric uncertainty is misestimated.
Nabarro et al. [45] modify the likelihood to accommodate data augmentation, using as the observation model the average of the neural network outputs over augmentations, but still ﬁnd a cold posterior effect.
In concurrent work, Bachmann et al.
[3] provide an alternative argument to how data augmentations introduce misspeciﬁcation due to correlation between errors which cold posteriors correct for.
Our paper makes several distinctive contributions in the context of prior work: (1) we argue that standard likelihoods do not represent our beliefs about aleatoric uncertainty, and that standard benchmarks have essentially no aleatoric uncertainty; (2) we show how tempering and data augmentation specify aleatoric uncertainty, beyond curation; (3) we show the precise way in which data augmentation with SGLD leads to underconﬁdence in the likelihood , a counterintuitive result which ﬁnally resolves the empirical connection between data augmentation and cold posteriors; (4) we show that
a
T < 1 , particularly with data augmentation, is a more honest reﬂection of our beliefs about aleatoric uncertainty than T = 1 ; (5) we show how the noisy Dirichlet likelihood, originally used for tractable
GP classiﬁcation [43], can naturally reﬂect our beliefs about aleatoric uncertainty, and for the ﬁrst time remove the cold posterior effect in the presence of data augmentation.
Background
Bayesian Model Averaging.
With Bayesian inference, we aim to infer the posterior distribution over parameters having observed a dataset D
= { ( x i , y i ) }
Ni =1 of input-output pairs, given by p ( w | D ) / p ( D | w ) p ( w ) for a given observation likelihood under the i.i.d.
assumption p ( D | w ) =
Q ( x,y ) 2 D p ( y | x, w ) , and prior over parameters p ( w ) .
For any novel input x ? , we compute the posterior predictive distribution via Bayesian model averaging (BMA) given by
[Equation]
The BMA integral in Eq. (1) cannot generally be expressed in closed form for a Bayesian neural network, and is typically approximated with variational inference (VI), the Laplace approximation, or Markov Chain Monte Carlo (MCMC)
[e.g., 62, 44].
Bayesian Classiﬁcation.
For a C -class classiﬁcation problem, a standard choice of observation likelihood is the categorical distribution p ( y | x, w ) =
Cat([ ⇡ 1 , . . .
, ⇡ C ]) , where each class probability is computed using a softmax transform of logits g ( x ; w ) =
[ g 1 ( x ; w ) , . . . , g C ( x ; w )] 2 R C as ⇡ c / f c ( x ; w ) = exp { g c ( x ; w ) } , and hence called the softmax likelihood . The prior over parameters p ( w ) is often chosen to be an isotropic Gaussian N
[Equation]
with some ﬁxed variance  2 .
Approximate posterior samples are often obtained via SGLD [60], and used for a Monte Carlo estimator of the BMA in Eq.
Cold Posteriors.
Let U ( w ) =
log p ( D | w )  log p ( w ) denote the posterior energy function of a BNN.
Following Wenzel et al.
[61], we deﬁne a cold posterior for T < 1 as
[Equation]
which effectively raises both the likelihood and the prior to a power 1 /T .
T = 1 recovers the standard Bayes’ posterior.
A tempered likelihood posterior (e.g. [17]) only raises the likelihood to a power 1 /T as
[Equation]
[-The prior over parameters p ( w ) is often chosen to be anisotropic Gaussian N  0 ,  
-]
Aleatoric Uncertainty in Bayesian Classiﬁcation
We will now discuss how we represent aleatoric uncertainty in classiﬁcation (Section 4.1), how tempering reduces aleatoric uncertainty (Section 4.2), and how we can explicitly represent aleatoric uncertainty without tempering with a noisy Dirichlet observation model (Section 4.3).
4.1 How do we represent aleatoric uncertainty in classiﬁcation?
Let us consider the Bayesian neural network posterior over parameters w in a classiﬁcation problem: p ( w | D ) / p ( w )
Q ( x,y ) 2 D f y ( x ; w ) , where we denote the output of the softmax layer of the model corresponding to class y on input x as f y ( x ; w ) .
Alternatively, we think of the class probability vectors f ( x ) , f ( x ; w ) = [ f 1 ( x ; w ) , . . . , f C ( x ; w )] as latent variables 2 in a C  1 simplex  C  1 , such that
P
Cc =1 f c ( x ; w ) = 1 .
The prior distribution p ( w ) over the parameters of the network implies a joint prior distribution over f ( x ) .
For simplicity, we assume that a prior over parameters p ( w ) implies a uniform prior over the class probability vectors through the Dirichlet distribution Dir. Given a single observation D 1 = { ( x, y ) } , inference involves constructing the posterior over the class probability vectors: the likelihood-prior product p ( f ( x ) | D 1 ) / f ( x ) p ( y | f ( x )) · Dir.
, 1)( f ( x )) . 3 Using the conjugacy of the Dirichlet prior to the standard classiﬁcation likelihood (a categorical distribution) [6, Ch. 2.2], we can now rewrite the observation model for an input x as
[Equation]
where the left hand side is equal to the right hand side of Eq.
(4) up to a scalar multiplier C !
(normalizing constant of the Dirichlet distribution), which does not depend on f ( x ) .
Eq.
(4) describes the distribution induced by the observation y on the predicted class probabilities for the corresponding input x by the likelihood.
Consequently, the joint posterior over the class probability vectors f = { f ( x ) } x 2 D with the full dataset can then be written as
[Equation]
Eq.
(5) provides intuition for how BNNs estimate aleatoric uncertainty in classiﬁcation.
If we further assume that the implied prior p ( f ) over f ( x ) for each x is uniform on  C  1 and independent across different inputs x , then for an observation ( x, y ) the posterior over f ( x ) is Dir.
. , 1) and the posterior mean for the probability of the correct class y is E [ f y ( x )] = 2 / ( C + 1) .
For example, with a dataset containing 100 classes (e.g. CIFAR-100), the model on average will only be less than 2% conﬁdent in the correct label on the training data !
In practice, however, the prior p ( w ) will imply a non-trivial joint distribution p ( f ) over { f ( x ; w ) } x 2 D , so the actual posterior may be more (or less) conﬁdent than suggested by the analysis above.
Moreover, we have a very limited understanding of the implied distribution p ( f ) [see 61, 62, for empirical analysis].
In particular, most practitioners use simple p ( w ) =
N (0 , ↵ 2 I ) priors, regardless of the amount of label noise in the data.
Explicitly constructing a prior in the parameter space that leads to highly conﬁdent predictive distributions over f ( x ) is challenging, but we will show how modifying the likelihood can be viewed as providing an input-dependent prior that more accurately reﬂects our beliefs about aleatoric uncertainty in Section 4.3.
Eq.
(5) suggests two natural ways of modifying the posterior to account for the aleatoric uncertainty:
(i) increasing the Dirichlet concentration for the observed class (equivalent to likelihood tempering), or (ii) decreasing the concentration for the unobserved classes (noisy Dirichlet model).
Next, we describe both of these approaches in detail.
4.2 Likelihood tempering reduces aleatoric uncertainty
The tempered likelihood posterior over the parameters w in Eq. (3) for BNN classiﬁcation can be written as p temp
[Equation]
, where T is the temperature.
Analogous to the derivation above, we can rewrite the corresponding function space posterior as
[Equation]
In other words, the tempered posterior corresponds to the same model as the regular posterior, but assumes that we observed 1 /T counts of class y for each input x in the training data.
Assuming the prior p ( w ) implies a uniform distribution over f ( x ; w ) , the conﬁdence in the correct labels on the train data under the tempered posterior E [ f y ( x )] = (1 + 1 /T ) /
( C + 1 /T ) .
For a dataset withclasses, at T = 10  2 we get a much higher average conﬁdence of more than 50% on the training data, much higher than the 2% for the standard observation model.
Tempering the Likelihood vs Posterior.
Prior work has mostly considered tempering the full
Bayesian posterior as opposed to just the likelihood (see Section 3).
In Appendix G.2 we show that tempering the full Bayesian posterior is almost always equivalent to changing the prior distribution, and tempering the likelihood, and that likelihood tempering recovers the cold posterior effect.
How should we think about tempering?
Prior work has asserted that posterior tempering sharply deviates from the Bayesian paradigm and the cold posterior effect is highly problematic [61, 48, 14].
We, on the other hand, argue that likelihood tempering is in fact a practical way to incorporate our assumptions about aleatoric uncertainty.
Relatedly, Aitchison [2] argue that the cold posterior effect can be caused by data curation.
For example, CIFAR- 10 and ImageNet datasets have relatively very little label noise and are carefully curated [e.g. 53].
Thus, we may expect that tempered likelihoods with low temperatures will lead to optimal performance.
Is a Tempered Likelihood a Valid Likelihood?
The observation model is a distribution p ( y | x ) over the labels conditioned on the input.
The tempered softmax likelihood is in general not a valid likelihood because it does not sum to 1 over classes.
But Wenzel et al.
[61] argue that the tempered softmax likelihood with T < 1 can be interpreted as a valid likelihood if we introduce a new class which is not observed in the training data.
Moreover, from Eq.
(6), we can naturally interpret the tempered likelihood as using the multinomial observation model, assuming 1 /T counts of the label are observed for each of the training datapoints, which is uncontroversial and perfectly valid. Smoothed softmax model.
Guo et al.
[19] show that softmax temperature scaling can be used to ﬁx the uncertainty calibration of trained neural networks.
Analogously, we can simply divide the logits of the model by a scalar temperature T , before computing the softmax likelihood, resulting in the smoothed softmax model , a valid Bayesian model with a tunable temperature parameter.
In Appendix F, we show that the smoothed softmax behaves differently than the tempered softmax likelihood, and is insufﬁcient to model the aleatoric uncertainty in Bayesian classiﬁcation. In particular, Figure 10 shows that the smoothed softmax likelihood does not address the cold posterior effect. 4.3 Noisy Dirichlet model: changing the prior over class probabilities
As we have seen in Eq.
(6), likelihood tempering increases the posterior conﬁdence by increasing the Dirichlet concentration for the observed class y from 2 to 1 + 1 /T .
We can achieve a similar effect by decreasing the concentration of the unobserved classes 4 .
Indeed, consider the distribution
[Equation]
position y , ↵ ✏
[Equation]
where ND in p ND stands for noisy Dirichlet and ↵ ✏ is a tunable parameter.
The noisy Dirichlet model was originally proposed by Milios et al.
[43] in the context of Gaussian process classiﬁcation, where they designed a tractable approximation to this model.
Using our running example, if p ( w ) induces a uniform distribution over f ( x ; w ) , for a problem with 100 classes and ↵ ✏ = 10  2 we have expected conﬁdence E [ f y ( x )]
= ( ↵ ✏ + 1) /
( C ↵ ✏ + 1) , slightly more than 50 % , similar to the tempered likelihood with T = 10  2 .
Going back to the parameter space, we can write the posterior distribution over w corresponding to the noisy Dirichlet model as
[Equation]
The noisy Dirichlet model exactly corresponds to a different prior.
Using the conjugacy of the Dirichlet and multinomial distributions [e.g., 6, Ch. 2.2.1], we can rewrite p ND from Eq. (8) as follows:
[Equation]
We can interpret q ND ( w ) , p ( w ) ·
[Equation] [Equation] ↵ [Equation]
, ↵ [Equation]
)( f ( x ; w )) as a prior over the parameters w of the model.
Indeed, q ND ( w ) does not depend on the labels y , and simply forces the predicted class probabilities to be conﬁdent in any one of the classes for the training data.
Then, the only difference between the noisy Dirichlet model in Eq.
(9) and the standard Bayesian neural network for classiﬁcation is the choice of the prior over the parameters: instead of using a generic prior p ( w ) such as the standard Gaussian distribution, we use the noisy Dirichlet prior q ND .
The noisy Dirichlet prior is intuitively appealing: in many practical settings a priori we believe that the aleatoric uncertainty on the training data is low, and the model should be conﬁdent in one of the classes.
At the same time, we would not want to enforce low aleatoric uncertainty everywhere in the input space, as we do not expect that all the possible inputs to the model should be classiﬁed with high conﬁdence.
The noisy Dirichlet model is a valid Bayesian model. In short, the noisy Dirichlet model corresponds to using a valid likelihood — the softmax likelihood — with a prior that explicitly enforces the model predictions to be conﬁdent on the training data.
In Section 6.2 we will see that the noisy Dirichlet model removes the cold posterior effect.
Gaussian approximation.
Milios et al.
[43] considered the distribution in Eq.
(9) in the context of
Gaussian process classiﬁcation, but with a different goal: they aimed to create a regression likelihood which would approximate the softmax likelihood.
We describe their Gaussian approximation which amounts to solving a regression problem in the space of logits z ( x ) with a Gaussian observation model in Appendix D. While theoretically we do not need to use the Gaussian approximation for
Bayesian neural networks and can directly use Eq.
(9), we found that in practice the approximation is much more stable numerically.
We use the Gaussian approximation in all experiments.
The Effect of Data Augmentation
Data augmentation is a key ingredient of modern deep learning.
Surprisingly, however, data augmentation has not been studied in the context of Bayesian methods until recently.
Several works have shown that data augmentation often causes the cold posterior effect in BNNs [31, 64, 14, 45].
We show that data augmentation, as applied in practice 5 , is closely connected to likelihood tempering with T > 1 .
In this case, the cold posteriors counterbalance the effect of data augmentation.
First, we consider the interaction between data augmentation and SGLD (or, equivalently, any other
SGMCMC method).
With SGLD, we aim to construct an unbiased estimator of the gradient of the posterior log-density (see Appendix C).
In prior work, e.g. in Wenzel et al.
[61], the stochastic gradient is estimated using a randomly augmented mini-batch of the data.
For a minibatch of the full dataset D m = { x i , y i } mi =1 ⇢ D , and a ﬁnite set of augmentations T = { t 1 , . . .
, t K } , this stochastic gradient is given by r
[Equation]
p
[Equation]
w ) , where the transformations t j are sampled uniformly from T .
There are two sources of randomness in r e
U ( w ) — the choice of the mini-batch D m and the choice of augmentation t j used for each x i .
The limiting distribution of SGLD is determined by the expectation of the stochastic gradient above, given by
N
[Equation]
where t j ⇠ T are augmentations sampled uniformly from T .
Therefore, we conclude that the limiting distribution of SGLD under data augmentation is given by
[Equation]
We can interpret the limiting distribution in Eq.
(11) as a tempered likelihood posterior for a new dataset D
= { ( t j ( x i ) , y i ) } i,j which contains all augmentations of every data point from the original dataset
D .
Furthermore, the likelihood is tempered with a temperature K > 1 , corresponding to a warm posterior .
In other words, the limiting distribution of SGLD with data augmentation corresponds to a posterior over the augmented dataset with a softened likelihood, leading to less conﬁdence about the labels.
By applying a cold temperature T = 1 /K to the posterior in Eq.
(11), we can recover the standard Bayesian posterior on the augmented dataset D 0 .
In Section 6.2, we explore the effect of data augmentation on aleatoric uncertainty in practice and show that it does indeed soften the likelihood and lead to increased aleatoric uncertainty.
What about Other Inference Procedures?
While the derivation in Eq.
(11) comes directly from studying the stochastic gradient evaluated in SGMCMC, we can equivalently derive the same posterior distribution in stochastic variational inference [26] as we show in Appendix I.
Should we always use temperature T = 1 /K ?
While using the temperature T = 1 /K recovers the standard Bayesian posterior on the augmented dataset D 0 , it is not necessarily a correct approach to modeling data augmentation.
Indeed, the standard posterior p ( w | D 0 ) / p ( w )
Q
Ni =
Q
Kj =1 p ( y i | t j ( x i )) assumes independence across both augmentations and data points.
In practice, however, we share the same label
y i across all the augmented versions of the image; treating the observations as independent then leads to underestimating the aleatoric uncertainty.
Indeed, consider the extreme scenario, where all the augmentations t j ( x ) simply return x .
In this case, treating the observations ( t j ( x ) , y ) as independent will simply raise the likelihood to a power of K , while in reality we have not received any additional information from the augmentation policy.
Correcting the likelihood by a factor of 1 /K is the correct approach only when the predictions on t j ( x ) are completely independent from each other (see Section 6.1).
See also Nabarro et al.
[45] for a related discussion.
Experiments
In this section we provide empirical support for the observations presented in Sections 4 and 5.
First, in Section 6.1 we visualize the effect of data augmentation on the limiting distribution of SGMCMC using a Gaussian process regression model.
Next, in Section 6.2 we report the results for BNNs on image classiﬁcation problems.
In Appendix E we additionally illustrate the effects of tempering, noisy Dirichlet model and data augmentation using a Bayesian neural network on a synthetic 2-D classiﬁcation problem. Appendix K provides detailed numerical results for reference.
All results report the mean and one standard deviation over 3 trials.
The code to reproduce experiments is available at github.com/activatedgeek/understanding-bayesian-classiﬁcation.
6.1 Visualizing the Effect of Data Augmentation
To illustrate our analysis in Section 5 we show the posterior in Eq.
(11) under data augmentation in a Gaussian process (GP) regression model.
We use a GP with a RBF kernel, noting that data points where k ( x, x 0 ) ⇡ 0 are effectively independent from each other, which occurs when k x  x 0 k   .
Consequently, the implied correlations between inputs beyond the distance  are zero.
We use augmented samples that are given by t j ( x ) = x + ⌧ j , for vectors { ⌧ j } Kj =1 such that k ⌧ j k   , assuming
that k ( x, t j ( x 0 )) =
for all datapoints x, x 0 and all augmentations t j .
Thus, the outputs of the GP on the training data are independent from the outputs on the augmented datapoints.
We show the posterior near the original data in Eq.
(11) for K = 1 , 4 and 10 augmentations per datapoint in Figure 2.
As the predictions on the train data are independent from the predictions on the augmented datapoints, the posterior in Eq.
(11) corresponds to tempering the posterior on the original training data with a warm temperature equal to the number K of augmentations.
As a result, increasing K softens the likelihood, leading to a less conﬁdent ﬁt on the training data.
6.2 Image Classiﬁcation with Bayesian Neural Networks
In this section we experimentally verify the results of the analysis in Sections 4 and 5 for Bayesian neural networks in image classiﬁcation problems.
First, we show that both the noisy Dirichlet model and tempered softmax likelihood can be successfully used to express our beliefs about the amount of label noise in the data.
Then, we show that the noisy Dirichlet model does not require tempering to achieve optimal performance.
Finally, we show that data augmentation softens the likelihood for
BNNs, and that the optimal temperature depends on the complexity of the data augmentation policy.
For all experiments we use a ResNet-18 model [20] and the CIFAR-10 [35] and Tiny Imagenet [36] datasets.
We use the SGLD sampler with a cyclical learning rate schedule [60, 65] to sample from the posterior.
We provide details on the hyper-parameters in Appendix L.
[Figure]
Accounting for the label noise via the noisy Dirichlet model or the tempered softmax likelihood signiﬁcantly improves accuracy accross the board.
Moreover, the best performance is achieved by different values of temperature T ⇤ in the tempered softmax likelihood or noise ↵ ⇤ ✏ in the noisy
Dirichlet model, i.e. no one model describes the data optimally across all levels of label noise.
Modeling label noise.
In classiﬁcation problems the aleatoric uncertainty corresponds to the amount of label noise in the data.
Throughout the paper we argued that aleatoric uncertainty is misrepresented by standard Bayesian neural networks, and that likelihood tempering and the noisy
Dirichlet model are compelling approaches to incorporate information about the amount of label noise.
In Figure 3, we show the BMA test accuracy and negative log-likelihood for the standard softmax likelihood, tempered softmax likelihood and the noisy Dirichlet model on CIFAR- 10 and
Tiny Imagenet under varying amounts of label noise.
We plot the results for the best performing temperature T 2 [10  5 , 10] or noise ↵ ✏ 2 [10  6 , 10  1 ] for the noisy Dirichlet model.
On both datasets and across label noises, we can signiﬁcantly improve performance over the softmax likelihood by explicitly modeling the aleatoric uncertainty with either tempering or the noisy Dirichlet model.
Moreover, different amounts of label noise require different values of T and ↵ ✏ parameters.
with ↵ ✏ =10  6 and the softmax likelihood as a function of temperature on CIFAR10.
The noisy Dirichlet model shows no cold posterior effect.
No cold posterior effect in the noisy Dirichlet model.
We explore the effect of posterior tempering on the standard softmax classiﬁcation likelihood and the noisy Dirichlet model with noise parameter ↵ ✏ =10  6 .
In Figure 4 we show the results on the
CIFAR-10 dataset.
As reported by Wenzel et al.
[61], for the standard softmax likelihood, tempering is required to achieve optimal performance, with T =10  3 providing the best results.
For the noisy Dirichlet model on the other hand, tempering does not signiﬁcantly improve the results with roughly constant performance across the temperature values.
In particular, the noisy Dirichlet model achieves near-optimal results at T =1 .
These results agree with our analysis in Section 4: both tempering and the noisy Dirichlet model are alternative ways of expressing our beliefs about the aleatoric uncertainty in the data; with the noisy Dirichlet model, we can achieve strong results without any need for tempering.
Data augmentation leads to underﬁtting on train data.
In Figure 5a we show the BMA train negative log-likelihood for the models trained with and without data augmentation.
Across temperatures for the tempered softmax and ↵ ✏ parameters for the noisy Dirichlet model, adding data augmentations reduces the quality of the
[Figure]
ﬁt on the original training data.
This result is analogous to the GP results in Section 6.1 and our analysis in Section 5: data augmentation softens the likelihood, leading to a more diffuse ﬁt.
Complex augmentations require lower temperatures.
In Section 5 we showed that under data augmentation the likelihood is effectively tempered with a temperature K , assuming the predictions on the augmented datapoints are completely independent from the original datapoints.
In practice however, the augmentations can be close to the original images, and the corresponding predictions can be highly correlated.
In Figure 5b, we consider ﬁve separate types of augmentations for ResNet- 18 on CIFAR- 10 at various posterior temperatures: horizontal and vertical ﬂips, random crops, combinations of ﬂips and crops, and AugMix [23] — an augmentation policy employing a very diverse set of transformations.
We ﬁnd that, as predicted by the analysis in Section 5, the optimal temperatures are different for different policies: in terms of test NLL, the simple policies (vertical and horizontal ﬂips) corresponding to K = 2 work best at warmer temperatures T = 1 , intermediate policies (crops and crops + ﬂips) corresponding to K ⇡ 100 require lower temperatures
T 2 [10  2 , 10  1 ] , and the most complex AugMix policy requires the lowest temperature T  10  4 .
Robustness to corruptions.
Finally, we consider robustness to dataset corruptions by considering the CIFAR- 10 C dataset [22], evaluating our models with both tempered softmax (TS) and noisy
Dirichlet models.
A full plot is shown in Appendix K; summarizing those results, we see that TS has the best performance at T = 10  3 with an accuracy of 93 . 2 (with T = 1 again under-performing), while again the noisy Dirichlet model performs well, with an accuracy of 92 . 6 (at ↵ ✏ = 10  4 ).
Discussion
A correct representation of aleatoric uncertainty is crucial to achieve strong performance with
Bayesian neural networks.
Standard Bayesian classiﬁers have no explicit mechanism to represent our beliefs about aleatoric uncertainty, which can lead to inadequate ﬁts to the training data.
This effect is exaggerated by data augmentation, which softens the likelihood, making the models underconﬁdent on the training data.
Posterior tempering is a simple and practical way to correct for this misspeciﬁcation and express our beliefs about the aleatoric uncertainty: most benchmark datasets have very low levels of label noise, and we can express this belief by tempering the softmax likelihood.
We also showed that we can achieve a similar effect without tempering, by using a prior that forces the model to be conﬁdent on the training datapoints with the noisy Dirichlet model. Acknowledgements
We would like to thank Micah Goldblum and Wanqian Yang for helpful comments.
This research is supported by an Amazon Research Award, NSF I-DISRE 193471, NIH R01DA048764-01A1, NSF
IIS-1910266, and NSF 1922658 NRT-HDR: FUTURE Foundations, Translation, and Responsibility for Data Science.
This work is supported in part through the NYU IT High Performance Computing resources, services, and staff expertise.
Checklist
For all authors...
(a) Do the main claims made in the abstract and introduction accurately reﬂect the paper’s contributions and scope?
[Yes] (b) Did you describe the limitations of your work?
[Yes] Appendix A. (c) Did you discuss any potential negative societal impacts of your work?
[Yes] Appendix A. (d) Have you read the ethics review guidelines and ensured that your paper conforms to them?
[Yes] 2.
If you are including theoretical results... (a) Did you state the full set of assumptions of all theoretical results?
[Yes] See Eq.
(10), Appendices G and I. (b) Did you include complete proofs of all theoretical results?
[Yes] See Eq.
(10), Appendices G and I 3. If you ran experiments... (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
[Yes] (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
[Yes] (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[Yes] Unless otherwise stated, mean and standard deviation over 3 trials.
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
[Yes] Appendix L. 4.
If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... (a) If your work uses existing assets, did you cite the creators?
[Yes] CIFAR- 10 [35], TinyImagenet [36].
(b) Did you mention the license of the assets?
[Yes] CIFAR- 10 , MIT License, TinyImagenet, MIT License [36] (c) Did you include any new assets either in the supplemental material or as a URL?
[Yes]
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating?
[N/A] (e) Did you discuss whether the data you are using/curating contains personally identiﬁable information or offensive content?
[N/A] 5.
If you used crowdsourcing or conducted research with human subjects... (a) Did you include the full text of instructions given to participants and screenshots, if applicable?
[N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
[N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]