Combining Ensembles and Data Augmentation Can Harm Your Calibration

1 INTRODUCTION . Many success stories in deep learning ( Krizhevsky et al. , 2012 ; Sutskever et al. , 2014 ) are in restricted settings where predictions are only made for inputs similar to the training distribution . In real-world scenarios , neural networks can face truly novel data points during inference , and in these settings it can be valuable to have good estimates of the model ’ s uncertainty . For example , in healthcare , reliable uncertainty estimates can prevent over-confident decisions for rare or novel patient conditions ( Dusenberry et al. , 2019 ) . We highlight two recent trends obtaining state-of-the-art in uncertainty and robustness benchmarks . Ensemble methods are a simple approach to improve a model ’ s calibration and robustness ( Lakshminarayanan et al. , 2017 ) . The same network architecture but optimized with different initializations can converge to different functional solutions , leading to decorrelated prediction errors . By averaging predictions , ensembles can rule out individual mistakes ( Lakshminarayanan et al. , 2017 ; Ovadia et al. , 2019 ) . Additional work has gone into efficient ensembles such as MC-dropout ( Gal and Ghahramani , 2016 ) , BatchEnsemble , and its variants ( Wen et al. , 2020 ; Dusenberry et al. , 2020 ; Wenzel et al. , 2020 ) . These methods significantly improve calibration and robustness while adding few parameters to the original model . Data augmentation is an approach which is orthogonal to ensembles in principle , encoding additional priors in the form of invariant feature transformations . Intuitively , data augmentation enables the model to train on more data , encouraging the model to capture certain invariances with respect to its inputs and outputs ; data augmentation may also produce data that may be closer to an out-ofdistribution target task . It has been a key factor driving state-of-the-art : for example , Mixup ( Zhang et al. , 2018 ; Thulasidasan et al. , 2019a ) , AugMix ( Hendrycks et al. , 2020 ) , and test-time data augmentation ( Ashukha et al. , 2020 ) . A common wisdom in the community suggests that ensembles and data augmentation should naturally combine . For example , the majority of uncertainty models in vision with strong performance are 1Contact : ywen @ utexas.edu . Code : https : //github.com/google/edward2/tree/master/ experimental/marginalization_mixup . built upon baselines leveraging standard data augmentation ( He et al. , 2016 ; Hendrycks et al. , 2020 ) ( e.g. , random flips , cropping ) ; Hafner et al . ( 2018 ) cast data augmentation as an explicit prior for Bayesian neural networks , treating it as beneficial when ensembling ; and Hendrycks et al . ( 2020 ) highlights further improved results in AugMix when combined with Deep Ensembles ( Hansen and Salamon , 1990 ; Krogh and Vedelsby , 1995 ) . However , we find the complementary benefits between data augmentations and ensembels are not universally true . Section 3.1 illustrates the poor calibration of combining ensembles ( MC-dropout , BatchEnsemble and Deep Ensembles ) and Mixup on CIFAR : the model outputs excessive low confidence . Motivated by this pathology , in this paper , we investigate in more detail why this happens and propose a method to resolve it . Contributions . In contrast to prior work , which finds individually that ensembles and Mixup improve calibration , we find that combining ensembles and Mixup consistently degrades calibration performance across three ensembling techniques . From a detailed analysis , we identify a compounding under-confidence , where the soft labels in Mixup introduce a negative confidence bias that hinders its combination with ensembles . We further find this to be true for other label-based strategies such as label smoothing . Finally , we propose CAMixup to correct this bias , pairing well with ensembles . CAMixup produces new state-of-the-art calibration on both CIFAR-10/100 ( e.g. , 0.4 % and 2.3 % on CIFAR-10 and CIFAR-10C ) , building on Wide ResNet 28-10 for competitive accuracy ( e.g. , 97.5 % and 89.8 % ) and on ImageNet ( 1.5 % ) , building on ResNet-50 for competitive accuracy ( 77.4 % ) . 2 BACKGROUND ON CALIBRATION , ENSEMBLES AND DATA AUGMENTATION . 2.1 CALIBRATION . Uncertainty estimation is critical but ground truth is difficult to obtain for measuring performance . Fortunately , calibration error , which assesses how well a model reliably forecasts its predictions over a population , helps address this . Let ( Ŷ , P̂ ) denote the class prediction and associated confidence ( predicted probability ) of a classifier . Expected Calibration Error ( ECE ) : One notion of miscalibration is the expected difference between confidence and accuracy ( Naeini et al. , 2015 ) : EP̂ [ |P ( Ŷ = Y |P̂ = p ) − p| ] . ECE approximates this by binning the predictions in [ 0 , 1 ] under M equally-spaced intervals , and then taking a weighted average of each bins ’ accuracy/confidence difference . Let Bm be the set of examples in the mth bin whose predicted confidence falls into interval ( m−1M , m M ] . The bin Bm ’ s accuracy and confidence are : Acc ( Bm ) = 1 |Bm| ∑ xi∈Bm 1 ( ŷi = yi ) , Conf ( Bm ) = 1 |Bm| ∑ xi∈Bm p̂i , ( 1 ) where ŷi and yi are the predicted and true labels and p̂i is the confidence for example xi . Given n examples , ECE is ∑M m=1 |Bm| n ∣∣∣Acc ( Bm ) − Conf ( Bm ) ∣∣∣ . 2.2 ENSEMBLES . Aggregating the predictions of multiple models into an ensemble is a well-established strategy to improve generalization ( Hansen and Salamon , 1990 ; Perrone and Cooper , 1992 ; Dietterich , 2000 ) . BatchEnsemble : BatchEnsemble takes a network architecture and shares its parameters across ensemble members , adding only a rank-1 perturbation for each layer in order to decorrelate member predictions ( Wen et al. , 2020 ) . For a given layer , define the shared weight matrix among K ensemble members as W ∈ Rm×d . A tuple of trainable vectors rk ∈ Rm and sk ∈ Rn are associated with each ensemble member k. The new weight matrix for each ensemble member in BatchEnsemble is W′k = W ◦ Fk , where Fk = rks > k ∈ Rm×d , ( 2 ) where ◦ denotes the element-wise product . Applying rank-1 perturbations via r and s adds few additional parameters to the overall model . We use an ensemble size of 4 in all experiments . MC-Dropout : Gal and Ghahramani ( 2016 ) interpret Dropout ( Srivastava et al. , 2014 ) as an ensemble model , leading to its application for uncertainty estimates by sampling multiple dropout masks at test time in order to ensemble its predictions . We use an ensemble size of 20 in all experiments . Deep Ensembles : Composing an ensemble of models , each trained with a different random initialization , provides diverse predictions ( Fort et al. , 2019 ) which have been shown to outperform strong baselines on uncertainty estimation tasks ( Lakshminarayanan et al. , 2017 ) . We use an ensemble size of 4 in all experiments . In this work , we focus on the interaction between data augmentation strategies and BatchEnsemble , MC-Dropout , and deep ensembles . Other popular ensembling approaches leverage weight averaging such as Polyak-Ruppert ( Ruppert , 1988 ) , checkpointing ( Huang et al. , 2017 ) , and stochastic weight averaging ( Izmailov et al. , 2018 ) to collect multiple sets of weights during training and aggregate them to make predictions with only a single set . 2.3 DATA AUGMENTATION . Data augmentation encourages a model to make invariant predictions under desired transformations which can greatly improve generalization performance . For example , in computer vision , random leftright flipping and cropping are de-facto approaches ( He et al. , 2016 ) . We highlight two state-of-the-art techniques which we study . Mixup : Mixup ( Zhang et al. , 2018 ) manipulates both the features and the labels in order to encourage linearly interpolating predictions . Given an example ( xi , yi ) , Mixup applies x̃i = λxi + ( 1− λ ) xj , ỹi = λyi + ( 1− λ ) yj . ( 3 ) Here , xj is sampled from the training dataset ( taken from the minibatch ) , and λ ∼ Beta ( a , a ) for a fixed hyperparameter a > 0 . Mixup was shown to be effective for generalization and calibration of deep neural networks ( Zhang et al. , 2018 ; Thulasidasan et al. , 2019b ) . Recent work has investigated why Mixup improves generalization ( Guo et al. , 2018 ; Shimada et al. , 2019 ) and adversarial robustness ( Beckham et al. , 2019 ; Pang et al. , 2020 ; Mangla et al. , 2020 ) . Given Mixup ’ s simplicity , many extensions have been proposed with further improvements ( Yun et al. , 2019 ; Berthelot et al. , 2019 ; Verma et al. , 2019 ; Roady et al. , 2020 ; Chou et al. , 2020 ) . AugMix : Searching or sampling over a set of data augmentation operations can lead to significant improvement on both generalization error and calibration ( Cubuk et al. , 2019b ; a ) . AugMix ( Hendrycks et al. , 2020 ) applies a sum of augmentations , each with random weighting , with a Jensen-Shannon consistency loss to encourage similarity across the augmentations . AugMix achieves state-of-the-art calibration across in- and out-of-distribution tasks . Let O be the set of data augmentation operations and k be the number of AugMix iterations . AugMix samples w1 , . . . , wk ∼ Dirichlet ( a , . . . , a ) for a fixed hyperparameter a > 0 and op1 , . . . , opk from O . Given an interpolation parameter m , sampled from Beta ( a , a ) , the augmented input x̃augmix is : x̃augmix = mxorig + ( 1−m ) xaug , xaug = k∑ i=1 wiopi ( xorig ) . ( 4 ) 3 MIXUP-ENSEMBLE PATHOLOGY . We seek to understand the effect of data augmentations on ensembles . In particular , we hope to verify the hypothesis of compounding improvements when combining the seemingly orthogonal techniques of data augmentation and ensembles . To our surprise , we find that augmentation techniques can be detrimental to ensemble calibration . 3.1 THE SURPRISING MISCALIBRATION OF ENSEMBLES WITH MIXUP . Ensembles are the most known and simple approaches to improving calibration ( Ovadia et al. , 2019 ; Lakshminarayanan et al. , 2017 ) , and Thulasidasan et al . ( 2019b ) showed that Mixup improves calibration in a single network . Motivated by this , Fig . 1 applies Mixup to each ensemble member on CIFAR-10/CIFAR-100 with WideResNet 28-10 ( Zagoruyko and Komodakis , 2016 ) . Here , we searched over Mixup ’ s optimal hyperparameter α ( Eq . 3 ) and found that α = 1 gives the best result , which corroborates the finding in Zhang et al . ( 2018 ) . All data points in Fig . 1 are averaged over 5 random seeds . Figs . 1a and 1b demonstrate improved test accuracy ( Red ( ensembles without Mixup ) to Blue ( ensembles with Mixup ) ) . However , if we shift focus to Figs . 1c and 1d ’ s calibration error , it is evident that combining Mixup with ensembles leads to worse calibration ( Red to Blue ) . This is counterintuitive as we would expect Mixup , which improves calibration of individual models ( Thulasidasan et al. , 2019a ) , to also improve the calibration of their ensemble . Fig . 1 confirms this pattern across BatchEnsemble ( BE ) , MC-dropout ( MC ) , and deep ensembles ( DE ) . This pathology also occurs on ImageNet , as seen in Table 1 . Why do Mixup ensembles degrade calibration ? To investigate this in more detail , Fig . 2 plots a variant of reliability diagrams ( DeGroot and Fienberg , 1983 ) on BatchEnsemble . We bin the predictions into M = 15 equally spaced intervals based on their confidence ( softmax probabilities ) and compute the difference between the average confidence and the average accuracy as in Eq . 1 for each bin . Fig . 2 tracks this difference over varying confidence levels . A positive difference ( Acc−Conf ) implies under-confidence with respect to the true frequencies ; negative implies over-confidence ; and zero implies perfect calibration . The backbone model in Fig . 2 is BatchEnsemble with an ensemble size of 4 ( we also found this consistent for MC-Dropout and Deep-Ensemble ) . The figure presents 4 methods : Single : vanilla WideResNet 28-10 ; Mix- upSingle : WideResNet 28-10 model trained with Mixup ; BatchEnsemble : vanilla BatchEnsemble WideResNet 28-10 model ; MixupBE : BatchEnsemble WideResNet 28-10 model trained with Mixup . Fig . 2 shows that only models trained with Mixup have positive ( Acc− Conf ) values on the test set , which suggests that Mixup encourages under-confidence . Mixup ensemble ’ s under-confidence is also greater in magnitude than that of the individual Mixup models . This suggests that Mixup ensembles suffer from compounding under-confidence , leading to a worse calibration for the ensemble than the individual Mixup models ’ calibration . This is contrary to our intuition that ensembles always improves calibration . To further visualize this issue , Appendix C ’ s Fig . 8 investigates the confidence ( softmax probabilities ) surface of deep ensembles and Mixup when trained on a toy dataset consisting of 5 clusters , each with a different radius . We ensemble over 4 independently trained copies of 3-layer MLPs . Deep ensemble ’ s predictive confidence is plotted over the entire input data space in Fig . 8c . The resulting predictions are extremely confident except at the decision boundaries . Deep Ensemble still displays high confidence in the area nearest to the origin which is expected to have lower confidence level . On the other hand , Fig . 8d shows that Mixup-Ensemble is only confident in a very constrained area around the training clusters , leading to an overall under-confident classifier which confirms our postulation of compounding under-confidence .

Summary: This work analyses the interaction between data-augmentation strategies such as MixUp and model ensembles with regards to calibration performance. The authors note how strategies such as mixup and label smoothing, which reduce a single model's over-confidence, lead to degradation in calibration performance when such models are combined as an ensemble. Specifically, all techniques, taken individually, improve calibration by reducing overconfidence. However, in combination they lead to under-confident models and, therefore, worse calibration. Based on this analysis, the author's provide a simple technique which yields SOTA calibration performance on CIFAR-10, CIFAR-10-C, CIFAR-100 and CIFAR-100-C and ImageNet. The authors propose to dynamically enable and disable MixUp based on whether the model is over/under confident on a particular class, as judged on a validation dataset.