AugMix: A Simple Data Processing Method to Improve Robustness and Uncertainty

Dan Hendrycks, Norman Mu, Ekin D. Cubuk, Barret Zoph, Justin Gilmer, Balaji Lakshminarayanan

Introduction

Current machine learning models depend on the ability of training data to faithfully represent the data encountered during deployment. In practice, data distributions evolve (Lipton et al., 2018), models encounter new scenarios (Hendrycks & Gimpel, 2017), and data curation procedures may capture only a narrow slice of the underlying data distribution (Torralba & Efros, 2011). Mismatches between the train and test data are commonplace, yet the study of this problem is not. As it stands, models do not robustly generalize across shifts in the data distribution. If models could identify when they are likely to be mistaken, or estimate uncertainty accurately, then the impact of such fragility might be ameliorated. Unfortunately, modern models already produce overconfident predictions when the training examples are independent and identically distributed to the test distribution. This overconfidence and miscalibration is greatly exacerbated by mismatched training and testing distributions.

Small corruptions to the data distribution are enough to subvert existing classifiers, and techniques to improve corruption robustness remain few in number. Hendrycks & Dietterich (2019) show that classification error of modern models rises from 22% on the usual ImageNet test set to 64% on ImageNet-C, a test set consisting of various corruptions applied to ImageNet test images. Even methods which aim to explicitly quantify uncertainty, such as probabilistic and Bayesian neural networks, struggle under data shift, as recently demonstrated by Ovadia et al. (2019). Improving performance in this setting has been difficult. One reason is that training against corruptions only encourages networks to memorize the specific corruptions seen during training and leaves models unable to generalize to new corruptions (Vasiljevic et al., 2016; Geirhos et al., 2018). Further, networks trained on translation augmentations remain highly sensitive to images shifted by a single pixel (Gu et al., 2019; Hendrycks & Dietterich, 2019). Others have proposed aggressive data augmentation schemes (Cubuk et al., 2018), though at the cost of a computational increase. Chun et al. (2019) demonstrates that many techniques may improve clean accuracy at the cost of robustness while many techniques which improve robustness harm uncertainty, and contrariwise. In all, existing techniques have considerable trade-offs.

In this work, we propose a technique to improve both the robustness and uncertainty estimates of classifiers under data shift. We propose AugMix, a method which simultaneously achieves new state-of-the-art results for robustness and uncertainty estimation while maintaining or improving accuracy on standard benchmark datasets. AugMix utilizes stochasticity and diverse augmentations, a Jensen-Shannon Divergence consistency loss, and a formulation to mix multiple augmented images to achieve state-of-the-art performance. On CIFAR-10 and CIFAR-100, our method roughly halves the corruption robustness error of standard training procedures from 28.4% to 12.4% and 54.3% to 37.8% error, respectively. On ImageNet, AugMix also achieves state-of-the-art corruption robustness and decreases perturbation instability from 57.2% to 37.4%. Code is available at https://github.com/google-research/augmix.

Related Work

Robustness under Data Shift. Geirhos et al. (2018) show that training against distortions can often fail to generalize to unseen distortions, as networks have a tendency to memorize properties of the specific training distortion. Vasiljevic et al. (2016) show training with various blur augmentations can fail to generalize to unseen blurs or blurs with different parameter settings. Hendrycks & Dietterich (2019) propose measuring generalization to unseen corruptions and provide benchmarks for doing so. Kang et al. (2019) construct an adversarial version of the aforementioned benchmark. Gilmer et al. (2018); Gilmer & Hendrycks (2019) argue that robustness to data shift is a pressing problem which greatly affects the reliability of real-world machine learning systems.

Calibration under Data Shift. Guo et al. (2017); Nguyen & O’Connor (2015) propose metrics for determining the calibration of machine learning models. Lakshminarayanan et al. (2017) find that simply ensembling classifier predictions improves prediction calibration. Hendrycks et al. (2019a) show that pre-training can also improve calibration. Ovadia et al. (2019) demonstrate that model calibration substantially deteriorates under data shift.

AugMix

AugMix is a data augmentation technique which improves model robustness and uncertainty estimates, and slots in easily to existing training pipelines. At a high level, AugMix is characterized by its utilization of simple augmentation operations in concert with a consistency loss. These augmentation operations are sampled stochastically and layered to produce a high diversity of augmented images. We then enforce a consistent embedding by the classifier across diverse augmentations of the same input image through the use of Jensen-Shannon divergence as a consistency loss.

Mixing augmentations allows us to generate diverse transformations, which are important for inducing robustness, as a common failure mode of deep models in the arena of corruption robustness is the memorization of fixed augmentations (Vasiljevic et al., 2016; Geirhos et al., 2018). Previous methods have attempted to increase diversity by directly composing augmentation primitives in a chain, but this can cause the image to quickly degrade and drift off the data manifold, as depicted in Figure 3. Such image degradation can be mitigated and the augmentation diversity can be maintained by mixing together the results of several augmentation chains in convex combinations. A concrete account of the algorithm is given in the pseudocode below.

Augmentations. Our method consists of mixing the results from augmentation chains or compositions of augmentation operations. We use operations from AutoAugment. Each operation is visualized in Appendix C. Crucially, we exclude operations which overlap with ImageNet-C corruptions. In particular, we remove the contrast, color, brightness, sharpness, and Cutout operations so that our set of operations and the ImageNet-C corruptions are disjoint. In turn, we do not use any image noising nor image blurring operations so that ImageNet-C corruptions are encountered only at test time. Operations such as rotate can be realized with varying severities, like 2∘2^{\circ} or −15∘-15^{\circ}. For operations with varying severities, we uniformly sample the severity upon each application. Next, we randomly sample kk augmentation chains, where k=3k=3 by default. Each augmentation chain is constructed by composing from one to three randomly selected augmentation operations.

Mixing. The resulting images from these augmentation chains are combined by mixing. While we considered mixing by alpha compositing, we chose to use elementwise convex combinations for simplicity. The kk-dimensional vector of convex coefficients is randomly sampled from a Dirichlet(α,…,α)\text{Dirichlet}(\alpha,\ldots,\alpha) distribution. Once these images are mixed, we use a “skip connection” to combine the result of the augmentation chain and the original image through a second random convex combination sampled from a Beta(α,α)\text{Beta}(\alpha,\alpha) distribution. The final image incorporates several sources of randomness from the choice of operations, the severity of these operations, the lengths of the augmentation chains, and the mixing weights.

Jensen-Shannon Divergence Consistency Loss. We couple with this augmentation scheme a loss that enforces smoother neural network responses. Since the semantic content of an image is approximately preserved with AugMix, we should like the model to embed xorigx_{\text{orig}}, xaugmix1x_{\text{augmix1}}, xaugmix2x_{\text{augmix2}} similarly. Toward this end, we minimize the Jensen-Shannon divergence among the posterior distributions of the original sample xorigx_{\text{orig}} and its augmented variants. That is, for porig=p^(y∣xorig),paugmix1=p^(y∣xaugmix1),paugmix2=p^(y∣xaugmix2)p_{\text{orig}}=\hat{p}(y\mid x_{\text{orig}}),p_{\text{augmix1}}=\hat{p}(y\mid x_{\text{augmix1}}),p_{\text{augmix2}}=\hat{p}(y|x_{\text{augmix2}}), we replace the original loss L\mathcal{L} with the loss

To interpret this loss, imagine a sample from one of the three distributions porig,paugmix1,paugmix2p_{\text{orig}},p_{\text{augmix1}},p_{\text{augmix2}}. The Jensen-Shannon divergence can be understood to measure the average information that the sample reveals about the identity of the distribution from which it was sampled.

This loss can be computed by first obtaining M=(porig+paugmix1+paugmix2)/3M=(p_{\text{orig}}+p_{\text{augmix1}}+p_{\text{augmix2}})/3 and then computing

Unlike an arbitrary KL Divergence between porigp_{\text{orig}} and paugmixp_{\text{augmix}}, the Jensen-Shannon divergence is upper bounded, in this case by the logarithm of the number of classes. Note that we could instead compute JS(porig;paugmix1)\text{JS}(p_{\text{orig}};p_{\text{augmix1}}), though this does not perform as well. The gain of training with JS(porig;paugmix1;paugmix2;paugmix3)\text{JS}(p_{\text{orig}};p_{\text{augmix1}};p_{\text{augmix2}};p_{\text{augmix3}}) is marginal. The Jensen-Shannon Consistency Loss impels to model to be stable, consistent, and insensitive across a diverse range of inputs (Bachman et al., 2014; Zheng et al., 2016; Kannan et al., 2018). Ablations are in Section 4.3 and Appendix A.

Experiments

Datasets. The two CIFAR (Krizhevsky & Hinton, 2009) datasets contain small 32×32×332\times 32\times 3 color natural images, both with 50,000 training images and 10,000 testing images. CIFAR-10 has 10 categories, and CIFAR-100 has 100. The ImageNet (Deng et al., 2009) dataset contains 1,000 classes of approximately 1.2 million large-scale color images.

In order to measure a model’s resilience to data shift, we evaluate on the CIFAR-10-C, CIFAR-100-C, and ImageNet-C datasets (Hendrycks & Dietterich, 2019). These datasets are constructed by corrupting the original CIFAR and ImageNet test sets. For each dataset, there are a total of 15 noise, blur, weather, and digital corruption types, each appearing at 5 severity levels or intensities. Since these datasets are used to measure network behavior under data shift, we take care not to introduce these 15 corruptions into the training procedure.

The CIFAR-10-P, CIFAR-100-P, and ImageNet-P datasets also modify the original CIFAR and ImageNet datasets. These datasets contain smaller perturbations than CIFAR-C and are used to measure the classifier’s prediction stability. Each example in these datasets is a video. For instance, a video with the brightness perturbation shows an image getting progressively brighter over time. We should like the network not to give inconsistent or volatile predictions between frames of the video as the brightness increases. Thus these datasets enable the measurement of the “jaggedness” (Azulay & Weiss, 2018) of a network’s prediction stream.

Metrics. The Clean Error is the usual classification error on the clean or uncorrupted test data. In our experiments, corrupted test data appears at five different intensities or severity levels 1≤s≤51\leq s\leq 5. For a given corruption cc, the error rate at corruption severity ss is Ec,sE_{c,s}. We can compute the average error across these severities to create the unnormalized corruption error uCEc=∑s=15Ec,s\text{uCE}_{c}=\sum_{s=1}^{5}E_{c,s}. On CIFAR-10-C and CIFAR-100-C we average these values over all 15 corruptions. Meanwhile, on ImageNet we follow the convention of normalizing the corruption error by the corruption error of AlexNet (Krizhevsky et al., 2012). We compute CEc=∑s=15Ec,s/∑s=15Ec,sAlexNet\text{CE}_{c}=\sum_{s=1}^{5}E_{c,s}/\sum_{s=1}^{5}E_{c,s}^{\text{AlexNet}}. The average of the 15 corruption errors CEGaussian Noise,CEShot Noise,…,CEPixelate,CEJPEG\text{CE}_{\text{Gaussian Noise}},\text{CE}_{\text{Shot Noise}},\ldots,\text{CE}_{\text{Pixelate}},\text{CE}_{\text{JPEG}} gives us the Mean Corruption Error (mCE).

Perturbation robustness is not measured by accuracy but whether video frame predictions match. Consequently we compute what is called the flip probability. Concretely, for videos such as those with steadily increasing brightness, we determine the probability that two adjacent frames, or two frames with slightly different brightness levels, have “flipped” or mismatched predictions. There are 10 different perturbation types, and the mean across these is the mean Flip Probability (mFP). As with ImageNet-C, we can normalize by AlexNet’s flip probabilities and obtain the mean Flip Rate (mFR).

Training Setup. In the following experiments we show that AugMix endows robustness to various architectures including an All Convolutional Network (Springenberg et al., 2014; Salimans & Kingma, 2016), a DenseNet-BC (k=12,d=100k=12,d=100) (Huang et al., 2017) , a 40-2 Wide ResNet (Zagoruyko & Komodakis, 2016), and a ResNeXt-29 (32×432\times 4) (Xie et al., 2016). All networks use an initial learning rate of 0.10.1 which decays following a cosine learning rate (Loshchilov & Hutter, 2016). All input images are pre-processed with standard random left-right flipping and cropping prior to any augmentations. We do not change AugMix parameters across CIFAR-10 and CIFAR-100 experiments for consistency. The All Convolutional Network and Wide ResNet train for 100 epochs, and the DenseNet and ResNeXt require 200 epochs for convergence. We optimize with stochastic gradient descent using Nesterov momentum. Following Zhang et al. (2017); Guo et al. (2019), we use a weight decay of 0.00010.0001 for Mixup and 0.00050.0005 otherwise.

Results. Simply mixing random augmentations and using the Jensen-Shannon loss substantially improves robustness and uncertainty estimates. Compared to the “Standard” data augmentation baseline ResNeXt on CIFAR-10-C, AugMix achieves 16.6% lower absolute corruption error as shown in Figure 5. In addition to surpassing numerous other data augmentation techniques, Table 1 demonstrates that these gains directly transfer across architectures and on CIFAR-100-C with zero additional tuning. Crucially, the robustness gains do not only exist when measured in aggregate. Figure 12 shows that AugMix improves corruption robustness across every individual corruption and severity level. Our method additionally achieves the lowest mFP on CIFAR-10-P across three different models all while maintaining accuracy on clean CIFAR-10, as shown in Figure 6 (left) and Table 6. Finally, we demonstrate that AugMix improves the RMS calibration error on CIFAR-10 and CIFAR-10-C, as shown in Figure 6 (right) and Table 5. Expanded CIFAR-10-P and calibration results are in Appendix D, and Fourier Sensitivity analysis is in Appendix B.

2 ImageNet

Baselines. To demonstrate the utility of AugMix on ImageNet, we compare to many techniques designed for large-scale images. While techniques such as Cutout (Devries & Taylor, 2017) have not been demonstrated to help on the ImageNet scale, and while few have had success training adversarially robust models on ImageNet (Engstrom et al., 2018), other techniques such as Stylized ImageNet have been demonstrated to help on ImageNet-C. Patch Uniform (Lopes et al., 2019) is similar to Cutout except that randomly chosen regions of the image are injected with uniform noise; the original paper uses Gaussian noise, but that appears in the ImageNet-C test set so we use uniform noise. We tune Patch Uniform over 30 hyperparameter settings. Next, AutoAugment (Cubuk et al., 2018) searches over data augmentation policies to find a high-performing data augmentation policy. We denote AutoAugment results with AutoAugment* since we remove augmentation operations that overlap with ImageNet-C corruptions, as with AugMix. We also test with Random AutoAugment*, an augmentation scheme where each image has a randomly sampled augmentation policy using AutoAugment* operations. In contrast to AutoAugment, Random AutoAugment* and AugMix require far less computation and provide more augmentation variety, which can offset their lack of optimization. Note that Random AutoAugment* is different from RandAugment introduced recently by Cubuk et al. (2019): RandAugment uses AutoAugment operations and optimizes a single distortion magnitude hyperparameter for all operations, while Random AutoAugment* randomly samples magnitudes for each operation and uses the same operations as AugMix. MaxBlur Pooling (Zhang, 2019) is a recently proposed architectural modification which smooths the results of pooling. Now, Stylized ImageNet (SIN) is a technique where models are trained with the original ImageNet images and also ImageNet images with style transfer applied. Whereas the original Stylized ImageNet technique pretrains on ImageNet-C and performs style transfer with a content loss coefficient of and a style loss coefficient of 11, we find that using 0.50.5 content and style loss coefficients decreases the mCE by 0.6%. Later, we show that SIN and AugMix can be combined. All models are trained from scratch, except MaxBlur Pooling models which has trained models available.

Training Setup. Methods are trained with ResNet-50 and we follow the standard training scheme of Goyal et al. (2017), in which we linearly scale the learning rate with the batch size, and use a learning rate warm-up for the first 5 epochs, and AutoAugment and AugMix train for 180 epochs. All input images are first pre-processed with standard random cropping horizontal mirroring.

Results. Our method achieves 68.4% mCE as shown in Table 2, down from the baseline 80.6% mCE. Additionally, we note that AugMix allows straightforward stacking with other methods such as SIN to achieve an even lower corruption error of 64.1% mCE. Other techniques such as AutoAugment* require much tuning, while ours does not. Across increasing severities of corruptions, our method also produces much more calibrated predictions measured by both the Brier Score and RMS Calibration Error as shown in Figure 7. As shown in Table 3, AugMix also achieves a state-of-the art result on ImageNet-P at with an mFR of 37.4%, down from 57.2%. We demonstrate that scaling up AugMix from CIFAR to ImageNet also leads to state-of-the-art results in robustness and uncertainty estimation.

3 Ablations

We locate the utility of AugMix in three factors: training set diversity, our Jensen-Shannon divergence consistency loss, and mixing. Improving training set diversity via increased variety of augmentations can greatly improve robustness. For instance, augmenting each example with a randomly sampled augmentation chain decreases the error rate of Wide ResNet on CIFAR-10-C from 26.9% to 17.0% Table 4. Adding in the Jensen-Shannon divergence consistency loss drops error rate further to 14.7%. Mixing random augmentations without the Jenson-Shannon divergence loss gives us an error rate of 13.1%13.1\%. Finally, re-introducing the Jensen-Shannon divergence gives us AugMix with an error rate of 11.2%11.2\%. Note that adding even more mixing is not necessarily beneficial. For instance, applying AugMix on top of Mixup increases the error rate to 13.3%13.3\%, possibly due to an increased chance of manifold intrusion (Guo et al., 2019). Hence AugMix’s careful combination of variety, consistency loss, and mixing explain its performance.

Conclusion

AugMix is a data processing technique which mixes randomly generated augmentations and uses a Jensen-Shannon loss to enforce consistency. Our simple-to-implement technique obtains state-of-the-art performance on CIFAR-10/100-C, ImageNet-C, CIFAR-10/100-P, and ImageNet-P. AugMix models achieve state-of-the-art calibration and can maintain calibration even as the distribution shifts. We hope that AugMix will enable more reliable models, a necessity for models deployed in safety-critical environments.

References

Appendix A Hyperparameter Ablations

In this section we demonstrate that AugMix’s hyperparameters are not highly sensitive, so that AugMix performs reliably without careful tuning. For this set of experiments, the baseline AugMix model trains for 90 epochs, has a mixing coefficient of α=0.5\alpha=0.5, has 3 examples per Jensen-Shannon Divergence (1 clean image, 2 augmented images), has a chain depth stochastically varying from 1 to 3, and has k=3k=3 augmentation chains. Figure 8 shows that the performance of various AugMix models with different hyperparameters. Under these hyperparameter changes, the mCE does not change substantially.

Appendix B Fourier Analysis

A commonly mentioned hypothesis (Gilmer & Hendrycks, 2019) for the lack of robustness of deep neural networks is that they readily latch onto spurious high-frequency correlations that exist in the data. In order to better understand the reliance of models to such correlations, we measure model sensitivity to additive noise at differing frequencies. We create a 32×3232\times 32 sensitivity heatmap. That is, we add a total of 32×3232\times 32 Fourier basis vectors to the CIFAR-10 test set, one at a time, and record the resulting error rate after adding each Fourier basis vector. Each point in the heatmap shows the error rate on the CIFAR-10 test set after it has been perturbed by a single Fourier basis vector. Points corresponding to low frequency vectors are shown in the center of the heatmap, whereas high frequency vectors are farther from the center. For further details on Fourier sensitivity analysis, we refer the reader to Section 2 of Yin et al. (2019). In Figure 9 we observe that the baseline model is robust to low frequency perturbations but severely lacks robustness to high frequency perturbations, where error rates exceed 80%. The model trained with Cutout shows a similar lack of robustness. In contrast, the model trained with AugMix maintains robustness to low frequency perturbations, and on the mid and high frequencies AugMix is conspicuously more robust.

Appendix C Augmentation Operations

The augmentation operations we use for AugMix are shown in Figure 10.

We do not use augmentations such as contrast, color, brightness, sharpness, and Cutout as they may overlap with ImageNet-C test set corruptions. We should note that augmentation choice requires additional care. Guo et al. (2019) show that blithely applying augmentations can potentially cause augmented images to take different classes. Figure 11 shows how histogram color swapping augmentation may change a bird’s class, leading to a manifold intrusion.

Appendix D Additional results

We include various additional results for CIFAR-10, CIFAR-10-C and CIFAR-10-P below. Figure 12 reports accuracy for each corruption, Table 5 reports calibration results for various architectures and Table 6 reports clean error and mFR. We refer to Section 4.1 for details about the architecture and training setup.

Appendix E Calibration Metrics

Due to the finite size of empirical test sets, the RMS Calibration Error must be estimated by partitioning all nn test set examples into bb contiguous bins {B1,B2,…,Bb}\{B_{1},B_{2},\ldots,B_{b}\} ordered by prediction confidence. In this work we use bins which contain 100100 predictions, so that we adaptively partition confidence scores on the interval (Nguyen & O’Connor, 2015; Hendrycks et al., 2019b). Other works partition the interval with 15 bins of uniform length (Guo et al., 2017). With these bb bins, we estimate the RMS Calibration Error empirically with the formula