A statistical theory of cold posteriors in deep neural networks

1 INTRODUCTION . Recent work has highlighted that Bayesian neural networks ( BNNs ) typically have better predictive performance when we “ sharpen ” the posterior ( Wenzel et al. , 2020 ) . In stochastic gradient Langevin dynamics ( SGLD ) ( Welling & Teh , 2011 ) , this can be achieved by multiplying the log-posterior by 1/T , where the “ temperature ” , T is smaller than 1 ( Wenzel et al. , 2020 ) . Broadly the same effect can be achieved in variational inference by “ tempering ” , i.e . downweighting the KL term . As noted in Wenzel et al . ( 2020 ) , this approach has been used in many recent papers to obtain good performance , albeit without always emphasising the importance of this factor ( Zhang et al. , 2017 ; Bae et al. , 2018 ; Osawa et al. , 2019 ; Ashukha et al. , 2020 ) . These results are puzzling if we take the usual Bayesian viewpoint , which says that the Bayesian posterior , used with the right prior , and in combination with Bayes decision theory should give optimal performance ( Jaynes , 2003 ) . Thus , these results may suggest we are using the wrong prior . While new priors have been suggested ( e.g . Ober & Aitchison , 2020 ) , they give only minor improvements in performance — certainly nothing like enough to close the gap to carefully trained non-Bayesian networks . In contrast , tempered posteriors directly give performance comparable to a carefully trained finite network . The failure to develop an effective prior suggests that we should consider alternative explanations for the effectiveness of tempering . Here , we consider the possibility that it is predominantly ( but not entirely ) the likelihood , and not the prior that is at fault . In particular , we note that standard image benchmark datasets such as ImageNet and CIFAR-10 are carefully curated , and that it is important to consider this curation as part of our generative model . We develop a simplified generative model describing dataset curation which assumes that a datapoint is included in the dataset only if there is unanimous agreement on the class amongst multiple labellers . This model naturally multiplies the effect of each datapoint , and hence gives posteriors that closely match tempered or cold posteriors . We show that toy data drawn from our generative model of curation can give rise to optimal temperatures being smaller than 1 . Our model predicts that cold posteriors will not be helpful when the original underlying labels from all labellers are available . While these are not available for standard datasets such as CIFAR-10 , we found a good proxy : the CIFAR-10H dataset ( Peterson et al. , 2019 ) , in which ∼ 50 humans annotators labelled the CIFAR-10 test-set ( we use these as our training set , and use the standard CIFAR-10 training set for test-data ) . As expected , we find strong cold-posterior effects when using the original single-label , which are almost entirely eliminated when using the 50 labels from CIFAR-10H . In addition , curation implies that each label is almost certain to be correct , which is one way to understand the statistical patterns exploited by cold posteriors . As such , if we destroy this pattern by adding noise to the labels , the cold posterior effect should disappear . We confirmed that with increasing label noise , the cold posterior effect disappears and eventually reverses ( giving better performance at temperatures close to 1 ) . 2 BACKGROUND : COLD AND TEMPERED POSTERIORS . Tempered ( e.g . Zhang et al. , 2017 ) and cold ( Wenzel et al. , 2020 ) posteriors differ slightly in how they apply the temperature parameter . For cold posteriors , we scale the whole posterior , whereas tempering is a method typically applied in variational inference , and corresponds to scaling the likelihood but not the prior , log Pcold ( θ|X , Y ) = 1T log P ( X , Y |θ ) + 1 T log P ( θ ) + const ( 1 ) log Ptempered ( θ|X , Y ) = 1λ log P ( X , Y |θ ) + log P ( θ ) + const . ( 2 ) While cold posteriors are typically used in SGLD , tempered posteriors are usually targeted by variational methods . In particular , variational methods apply temperature scaling to the KL-divergence between the approximate posterior , Q ( θ ) and prior , L = EQ ( θ ) [ log P ( X , Y |θ ) ] − λDKL ( Q ( θ ) ||P ( θ ) ) . ( 3 ) Note that the only difference between cold and tempered posteriors is whether we scale the prior , and if we have Gaussian priors over the parameters ( the usual case in Bayesian neural networks ) , this scaling can be absorbed into the prior variance , 1 T log Pcold ( θ ) = − 1 2Tσ2cold ∑ i θ2i + const = − 12σ2tempered ∑ i θ2i + const = log Pcold ( θ ) . ( 4 ) in which case , σ2cold = σ 2 tempered/T , so the tempered posteriors we discuss are equivalent to cold posteriors with rescaled prior variances . 3 METHODS : A GENERATIVE MODEL FOR CURATED DATASETS . Standard image datasets such as CIFAR-10 and ImageNet are carefully curated to include only unambiguous examples of each class . For instance , in CIFAR-10 , student labellers were paid per hour ( rather than per image ) , were instructed that “ It ’ s worse to include one that shouldn ’ t be included than to exclude one ” , and then Krizhevsky ( 2009 ) “ personally verified every label submitted by the labellers ” . For ImageNet , Deng et al . ( 2009 ) required the consensus of a number of Amazon Mechanical Turk labellers before including an image in the dataset . To understand the statistical patterns that might emerge in these curated datasets , we consider a highly simplified generative model of consensus-formation . In particular , we draw a random image X from some underlying distribution over images , P ( X ) , and ask S humans to assign a label , { Ys } Ss=1 ( e.g . using Mechanical Turk ) . We force every labeller to label every image and if the image is ambiguous they are instructed to give a random label . If all the labellers agree , Y1=Y2= · · · =YS , consensus is reached and we include the datapoint in the dataset . If any of the labellers disagree consensus is not reached , and we exclude the datapoint ( Fig . 1 ) , Formally , the observed random variable , Y , is taken to be the usual label if consensus was reached and None if consensus was not reached ( Fig . 2B ) , Y | { Ys } Ss=1 = { Y1 if Y1=Y2= · · · =YS None otherwise ( 5 ) Taking the human labels , Ys , to come from the set Y , so Ys ∈ Y , the consensus label , Y , could be any of the underlying labels in Y , or None if no consensus is reached , so Y ∈ Y ∪ { None } . When consensus was reached , the likelihood is , P ( Y =y|X , θ ) = P ( { Ys=y } Ss=1|X , θ ) = S∏ s=1 P ( Ys=y|X , θ ) = P ( Ys=y|X , θ ) S ( 6 ) where we have assumed labellers are IID . This would appear to directly give an account of tempering , as we have taken the single-labeller likelihood to the power S , which is equivalent to setting λ = 1/S . However , to see how the full generative model functions we need to go on to consider the case in which consensus was not reached , P ( Y =None|X , θ ) = 1− ∑ y∈Y P ( Y =y|X , θ ) = 1− ∑ y∈Y P ( Ys=y|X , θ ) S . ( 7 ) To understand the impact of our model of consensus formation , note that the probability of a particular class-label can be separated into two terms , a probability of consensus , and the probability of a particular class given that consensus was reached , P ( Y =y|X , θ ) = P ( Y =y|Y 6=None , X , θ ) P ( Y 6=None|X , θ ) . ( 8 ) Remarkably , knowing there was consensus gives us information about the weights , even in the absence of the class label , P ( Y 6=None|X , θ ) = ∑ y∈Y P ( Ys=y|X , θ ) S , ( 9 ) in essence , telling us that the output probability was close to 1 for one of the class labels , without telling us which one . Schematically ( Fig . 3 ) , we see that the datapoints with a consensus class-label , “ cat ” or “ dog ” , lie far from the decision boundary where the class is unambiguous , and consensus is easily reached . In contrast , in regions close to the decision boundary the inputs are ambiguous , which tends to produce disagreement in the labellers , leading to noconsensus . Thus , the existence of one or more consensus points in a region implies that decision boundaries do not go through that region , giving us information about the decision boundary location , even if the label is not known . Concurrent work has shown that this likelihood can be used to explain classical semi-supervised likelihoods ( Aitchison , 2020 ) , so this term really does give information about the neural network parameters . Finally , the label probability , conditioned on consensus , P ( Y =y|Y 6=None , X , θ ) = P ( Y =y|X , θ ) P ( Y 6=None|X , θ ) = P ( Ys=y|X , θ ) S∑ y∈Y P ( Ys=y|X , θ ) S ( 10 ) simply represents a “ reparameterised ” softmax . In datasets where the noconsensus inputs are known it is clear we should use the full likelihood , ( Eq . 6 and 7 ) . The question is : in real-world datasets , where we only know the consensus inputs and the noconsensus inputs have been thrown away ( Fig . 2C ) , can we use Eq . ( 10 ) , a reparameterisation of the softmax-categorical probabilities , for the known consensus points ? The answer is no because in Bayesian inference , we do not get to just pick a sensible-looking conditional probability distribution , such as Eq . 10 , to use as the likelihood . Instead , we need to write down the full generative model , and marginalise over unknown latents . To write down the generative model in the case of unknown noconsensus images ( Fig . 2C ) , we need to take X to be an unobserved latent variable , and take Z to be an observed random variable , Z|X , { Ys } Ss=1 = { X if Y1=Y2= · · · =Ys None otherwise ( 11 ) which is the underlying image , X , if consensus is reached , and None otherwise . As Z depends on θ ( Fig . 2C ) , we can not take the usual shortcut of using P ( Y |Z , θ ) ; we must instead use the full likelihood , P ( Y , Z|θ ) , P ( Y , Z|θ ) = ∑ { Ys } Ss=1 ∫ dX P ( X , Y , { Ys } Ss=1 , Z|θ ) = ∑ { Ys } Ss=1 ∫ dX P ( X ) [ ∏S s=1 P ( Ys|X , θ ) ] P ( Y | { Ys } Ss=1 ) P ( Z|X , { Ys } Ss=1 ) . ( 12 ) for y not None , P ( Y = y| { Ys } Ss=1 ) = { 1 if Ys = y for all s ∈ { 1 , . . . , S } 0 otherwise ( 13 ) and , P ( Z|X , { Ys } Ss=1 ) = { δ ( Z −X ) if Y1 = Y2 = · · · = YS IZ=None otherwise ( 14 ) where δ is the Dirac-delta function , and where the indicator function , IZ=None is 1 if Z = None and 0 otherwise . Substituting Eq . ( 13 ) and Eq . ( 14 ) into Eq . ( 12 ) , P ( Y = y , Z|θ ) = P ( X ) S∏ s=1 P ( Ys = y|X , θ ) ∝ P ( Ys = y|X , θ ) S , ( 15 ) where the proportionality arises because P ( X ) does not depend on the parameters of interest , θ . Note that this is proportional to Eq . ( 6 ) above , and not Eq . ( 10 ) , so this does not just represent a reparameterisation of the softmax . Finally , this explanation for the cold posterior effect would suggest that we would see cold posteriors even in maximum a-posteriori ( MAP ) inference , as we confirm in Appendix A . This is expected as it is “ common knowledge ” ( but we do not know of a good reference ) that while weight-decay is closely related to MAP inference with Gaussian priors , the best performing value of the weight decay coefficient tend to be lower than those suggested by untempered MAP inference .

Summary: The work propose a theory suggesting that the cold posterior phenomena arises solely due the the curated nature of image benchmarks. A generative model is proposed where multiple annotators label datapoints, and only unanimously labeled datapoints are accepted into a dataset. This theory is studied under a toy-problem using VI and a relabelled version of the CIFAR-10 test set with SGLD.