Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Show the model the variations it will meet
A photo of a cat is still a cat if it is shifted a little, flipped left to right, made brighter or slightly cropped. If we only show the model each training photo exactly as it was taken, it may tie its answer to accidents such as where the cat sits in the frame. Data augmentation shows it many randomly altered versions instead, so it learns what stays the same: the cat.
Augmentation is often worth more than any architectural change when data are scarce, and it is essential for perception systems that must cope with lighting, viewpoint, weather and sensor noise they were not trained on. The same idea makes domain randomisation work for robots trained in simulation.
- 1. Data augmentation trains on…
- 2. Augmentation teaches the model…
- 3. In robotics, randomising simulator appearance is called…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Images:
- random resized crops; a 256 × 256 image has 33 × 33 = 1089 positions for a 224 × 224 crop;
- horizontal flips (array reversed along the width): [[1, 2, 3], [4, 5, 6]] → [[3, 2, 1], [6, 5, 4]];
- colour jitter: contrast c about the mean, brightness b, clipped to the valid range;
- small rotations, blur, noise.
- Audio and time series: time shifts (without wrap-around), time stretching, pitch shifts, added noise, and masking bands of time or frequency (SpecAugment).
- Label preservation is the rule:
- a horizontal flip is fine for cats but changes the meaning of text, of left/right turns, and of chirality;
- a vertical flip is wrong for street scenes;
- a time reversal is wrong when the direction of change is the label.
- Fresh randomness every epoch: each pass sees new transforms, so the effective dataset is much larger.
- 1. Crop positions for 224 × 224 in 256 × 256:
- 2. A horizontal flip is invalid for…
- 3. SpecAugment masks…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Augmentation in code
Exercise 1. On a toy task whose label is whether a bright bar is on the left or right of a 16 × 16 image, small crops and noise preserved the class of all 400 images, while horizontal flips changed the class of every one. Whether an augmentation is valid depends on the task.
Practice.
- Apply augmentation only to training data; at test time use the plain image (or test-time augmentation, averaging predictions over a few transforms).
- Automated policies:
- AutoAugment searches over sequences of operations;
- RandAugment picks N random operations at magnitude M, with only two hyperparameters;
- TrivialAugment picks one operation at random strength.
- Strength must match model size: big models trained long benefit from strong augmentation; small models can underfit with it.
- For detection and segmentation, transform the boxes and masks together with the image.
T = torchvision.transforms.v2
train_tf = T.Compose([T.RandomResizedCrop(224), T.RandomHorizontalFlip(), T.RandAugment(num_ops=2, magnitude=9), T.ToImage(), T.ToDtype(torch.float32, scale=True)])- 1. RandAugment's two hyperparameters are…
- 2. For detection, boxes must be…
- 3. Test-time augmentation…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Augmentation as prior knowledge. Choosing transforms says which changes should not affect the output. Training on transformed data pushes the model toward functions invariant to them, which shrinks the set of functions it can fit and so lowers variance (Chen, Dobriban and Lee, 2020).
Vicinal risk. Instead of minimising loss only at the training points (empirical risk), augmentation minimises it over a neighbourhood of each point (Chapelle et al., 2001). Mixup (E4-8) is a vicinal distribution that mixes pairs of examples.
Architecture versus augmentation. Convolutions build translation equivariance into the model; augmentation teaches it from data. For invariances an architecture does not encode, such as rotation in standard CNNs or position in an MLP, augmentation is the main tool. Exercise 2 is such a case.
Distribution shift. Augmentation helps most when the test data vary in ways the training data do not. If the augmentation’s range is much wider than reality, it wastes capacity on variations that never occur.
- 1. Augmentation lowers…
- 2. Vicinal risk minimises loss over…
- 3. Translation equivariance is built into…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Teaching a missing invariance
History.
- Y. LeCun et al. (1998) used distortions to train on handwritten digits.
- A. Krizhevsky et al. (2012) used crops, flips and colour changes for AlexNet.
- E. Cubuk et al. introduced AutoAugment (2019) and RandAugment (2020); D. Park et al. (2019) SpecAugment.
- J. Tobin et al. (2017) introduced domain randomisation for sim-to-real transfer.
Exercise 2. Signals of length 48 whose class is a rising or falling ramp, on white noise. In the 80 training signals the ramp always starts at positions 16–20; in the 1000 test signals it can be anywhere. An MLP (48 → 64 → 2, no built-in shift invariance) is trained with Adam for 1500 mini-batch steps, with fresh augmentation for each batch. Means of three seeds:
| augmentation | test accuracy | test cross-entropy |
|---|---|---|
| none | 0.445 | 2.718 |
| extra noise | 0.438 | 3.085 |
| random shifts (±16, no wrap) | 0.851 | 0.358 |
| time reversal (label-changing, used wrongly) | 0.513 | 3.889 |
- Without augmentation the network failed on ramps in new positions: 0.445, no better than guessing.
- Random shifts, which encode the true invariance, nearly doubled accuracy.
- Extra noise, though label-preserving, did nothing: it does not address the missing variation.
- Time reversal turns one class into the other, so it taught contradictory labels and left the network guessing.
- Lesson: an augmentation helps only if it preserves the label and covers variation the training data lack.
Augmentation in AI, robotics and aerospace
- Perception for autonomous vehicles and drones: weather, lighting and sensor-noise augmentation, plus simulation with domain randomisation.
- Satellite and aerial imagery: rotations and flips are valid (there is no “up”), which multiplies scarce labelled data.
- Fault and vibration data: time shifts, scaling and noise augmentations for classifiers trained on few failure cases.
References
- A. Krizhevsky, I. Sutskever, G. Hinton (2012). “ImageNet classification with deep convolutional neural networks.” Advances in NeurIPS.
- E. D. Cubuk, B. Zoph, J. Shlens, Q. V. Le (2020). “RandAugment: practical automated data augmentation with a reduced search space.” Proc. CVPR Workshops.
- D. S. Park et al. (2019). “SpecAugment: a simple data augmentation method for automatic speech recognition.” Proc. Interspeech.
- J. Tobin et al. (2017). “Domain randomization for transferring deep neural networks from simulation to the real world.” Proc. IROS.
- S. Chen, E. Dobriban, J. Lee (2020). “A group-theoretic framework for data augmentation.” JMLR 21.