Automatically Finding Useful Augmentations with Minimal Use of Compute

Categories computer vision

Cristian Duguet, Adrian Hutter, Nandika Kalra, Arshak Navruzyan


Data augmentation of images is a widely adopted technique to improve models generalization [3] by applying transformations (or sets of combined transformations) during training and optionally at test time. Often practitioners look for the best set of transformations manually, either by relying on domain expertise or making assumptions about generally useful transformations. This process of manual search for optimal augmentations can be time-consuming and compute intensive.

The library does a great job in providing smart defaults in other areas like setting hyperparameters, model architecture (e.g. custom head) and augmentations are no exception. After a lot of experimentation, the team has found a standard set of augmentations which is applied indiscriminately to every dataset, and has proven to work effectively most of the time. However, there may be room for improvement if the appropriate augmentations can be found for a given dataset in a fast way.

Over the last months, our team in has been working to create a method to automate the search for the best augmentation set, in a computationally efficient manner, and with as little domain-specific input as possible. The purpose of this research aligns with the goals of, which seeks to offer deep learning to a wider non-engineer audience.

Current approaches

There are a few approaches to automatically finding an optimal set of augmentations, but the most common paradigm is to generate various augmented datasets and fully or partially train “child models” with each set to determine impact on performance. The central focus of these approaches is to make the search as efficient as possible through gaussian process, reinforcement learning and other search methods.

One obvious disadvantage of this formulation is that they are not computationally cheap. In order to achieve even a modest improvement, thousands or tens of thousands of child models have to be trained and evaluated.

A more novel approach is from Ratner [5] where they use a GAN to find the set of transformation parameters to create augmented data which lies within a defined distribution of interest, representative of the training set. By treating the augmentation search as a sequence modeling problem, this approach attempts to find not only the right augmentations but also their parameterization, which can be non-differentiable and hence requires a reinforcement learning loop in addition to the generative and discriminative model training.

We are looking for a more computationally efficient way (at the sacrifice of any performance due to composability) for automatically finding a set of parameters for the image transform functions provided by the library.


The fastai library provides different types of image transformations which are used for data augmentation. These transformations can be grouped in affine, pixel, cropping, lighting and coordinate transformations. The default augmentation set, which is obtained by calling get_transforms() has the following parameters:

Table 1: List of transformations available in There are more transforms available in their documentation, but we focused on the ones listed





crop_padTfmCrop'row_pct': (0, 1), 'col_pct': (0, 1)




symmetric_warpTfmCoord'magnitude': (-0.2, 0.2)


rotateTfmAffine'degrees': (-10.0, 10.0)


zoomTfmAffine'row_pct': (0, 1), 'col_pct': (0, 1), 'scale': (1.0, 1.1)


brightnessTfmLighting'change': (0.4, 0.6)


contrastTfmLighting'scale': (0.8, 1.25)


Method Validation

The performance of the training set augmented with the chosen transformations will be compared to the performance of the training set augmented with the default augmentation set, by training both networks for a determined routine. This will be done for different datasets. The performance metric is the error rate on the validation set.


A variety of datasets and domains were selected to assess the robustness of this method. A group of datasets, which could be representative of very different use cases was gathered and the following 6 were selected.

TTA Search

The Test Time Augmentation is a technique to leverage the use of augmentation for prediction instead of training. With TTA, the probability of prediction of an image would comprise 2 different predictions:

p_{final} = \beta p_{original} + (1-\beta) p_{augmented}

Where p_{original} and p_{augmented} are the predicted values for the original and the augmented image, respectively, and \beta is a weight factor.

We have observed that the Test Time Augmentation can be a good indicator of when a certain augmentation is a good candidate for training. This means that if the average of all TTA predictions on a set using certain augmentation had higher accuracy than the average of normal predictions, then training the network with that augmentation will most likely improve the performance of the network.

Figure 1: Normalized error rate of a trained dataset with a certain augmentation vs normalized TTA for that augmentation as well. The normalization is the relative change to the baseline case. Each point is a different augmentation tried on the network, each color is an experiment on a different dataset.

We identified that very harmful transformations for training, which would be characterized by a high err/err_none and TTA_err/TTA_err_none value. For the Pets and Dogs dataset, for example, it was the dihedral transform, while for Planet it was resize_crop. Most transforms of our set were detrimental for CIFAR-10.

Based on the observed behaviour, we search for a certain augmentation set using TTA, in a procedure which works as follows.

  1. Split the training set into two subsets of size 80% and 20%, respectively.
  2. Train the last layer group on 80% of the training set for EPOCHS_HEAD epochs, without any data augmentation.
  3. Calculate the error rate ERR_NONE on the remaining 20% of the training set.
  4. For each kind of transformation, for each possible magnitude, calculate the TTA error rate on the remaining 20% of the training set. For TTA, we base predictions on WEIGHT_UNTRANSFORMED * LOGITS_UNTRANSFORMED + (1 - WEIGHT_UNTRANSFORMED) * LOGITS_TRANSFORMED. Where WEIGHT_UNTRANSFORMED describes the amount of influence the augmentation has on the prediction.
  5. For each kind of transformation, choose the magnitude which leads to the lowest TTA error rate, if that error rate is lower than THRESHOLD * ERR_NONE; otherwise, don’t include that kind of transformation in the final set of augmentations.
  6. With the chosen set of augmentations, train the head for EPOCHS_HEAD epochs and the full network for EPOCHS_FULL.
  7. As a baseline, train the network for the same number of epochs using the transforms provided by get_transforms().

Out of the transformations available in the library, we have tested our method with the following transforms/parameters list

Table 2: List of tested augmentations using our search method, including a list of the tested parameters.



Tested parameters


flipTfmAffineEither flip_affine, or dihedral_affine


symmetric_warpTfmCoord'magnitude': (-m, m) for m in [0.1,0.2,0.3,0.4]


rotateTfmAffine'degrees': (-m, m) for m in [10., 20., 30., 40.]


zoomTfmAffine'Scale': (1.,max_zoom) for max_zoom in [1.1, 1.2, 1.3, 1.4]


brightnessTfmLighting'change': (0.5*(1-max_lighting), 0.5*(1+max_lighting)) for max_lighting in [0.1, 0.2, 0.3, 0.4]


contrastTfmLighting'scale': (1-max_lighting, 1/(1-max_lighting)) for max_lighting in [0.1, 0.2, 0.3, 0.4]


skewTfmCoord'direction': (0,7), 'magnitude': max_skew for max_skew in [0.2, 0.4, 0.6, 0.8]


squishTfmAffine'scale': (1/max_scale, max_scale) for max_scale in [1.2, 1.8, 2.4, 3.]


rand_pad+cropTfPixel'padding': p for p in [size/16, size/8, size/4]


* that is the probability with which each transform was used for final training. For the TTA search method the probability was 1.0.


We have found that the Test Time Augmentation for transformation delivers information about the performance improvement with a particular augmentation, and helps rapidly deciding on image transformations which are constructive for better generalizing the network.

Table 3 shows the performance improvement by this method, in comparison to the baseline case. The list of augmentations picked out for each dataset are detailed in Table 4.

Table 3: Top-1 error rates for the found augmentation sets.


Baseline error rate

TTA Search

rel. improvement

Oxford-IIIT Pets




Stanford Dogs




Planet: Understanding the Amazon from Space
















UPDATE: The team has just reached SOTA performance in the dataset Food-101 using our augmentation search technique.

Table 4 : List of selected augmentations and its parameters, for each dataset. The values between brackets represent uniform distribution of the RandTransform class.

















[-0.1, 0.1]

[-0.1, 0.1]

[-0.2, 0.2]



[-0.2, 0.2]



[-20, 20]

[-20, 20]

[-10, 10]


[-10, 10]

[-40, 40]



[1.0, 1.3]

[1.0, 1.2]

[1.0, 1.2]


[1.0, 1.2]

[1.0, 1.4]




[0.45, 0.55]


[0.3, 0.7]

[0.45, 0.55]

[0.35, 0.65]




[0.7, 1.43]

[0.9, 1.11]

[0.9, 1.11]

[0.8, 1.25]

[0.7, 1.43]


(scale, magnitude)

[0, 7], 0.4


[0,7], 0.2


[0, 7], 0.4


[0, 7], 0.2

[0, 7], 0.2




[0.83, 1.2]

[0.83, 1.2]


[0.83, 1.2]

[0.42, 2.4]


It is worth noting that the augmentations picked by our method seemed qualitatively reasonable. For example, for the Planet dataset it chooses dihedral flips (which might include upside-down flips), while for Kuzushiji-MNIST it chooses neither left-right nor dihedral flips, since any of these flips would be damaging for the transformation.

With more time, it may be worth investigating how consistent the differences between the error rates are. The differences between the TTA-based selection of augmentations and get_transforms() might be smaller than the differences between different runs for the same set of augmentations.


We would like to thank Jeremy Howard for his insightful guidance and David Tedaldi for mentorship during this project.


  1. Cubuk, Ekin D., et al. AutoAugment: Learning Augmentation Policies from Data. arXiv preprint arXiv:1805.09501 (2018).
  2. Geng, Mingyang, et al. Learning data augmentation policies using augmented random search. arXiv preprint arXiv:1811.04768 (2018).
  3. Perez, Luis, et al. The Effectiveness of Data Augmentation in Image Classification using Deep Learning. arXiv preprint arXiv:1712.04621 (2017).
  4. Krizhevsky, Alex, et al. ImageNet Classification with Deep Convolutional Neural Networks. Neural Information Processing Systems. 25. 10.1145/3065386 (2012).
  5. Ratner, Alexander J., et al. Learning to compose domain-specific transformations for data augmentation. Advances in neural information processing systems. 2017.



Also published on Medium.

Leave a Reply

Your email address will not be published. Required fields are marked *