Enlarging the dataset with transformations that preserve the label
- : a random transformation applied at load time.
A flipped photograph of a cat is still a cat, so the pair is still valid training data and the model has seen one more example.
The condition is the label. Flipping a photograph horizontally is safe. Flipping a digit is not, because a mirrored 2 is not a 2.
Training minimises the loss averaged over the transformations, which teaches the model to be invariant to exactly the ones you chose.
That makes augmentation a way of stating what should not matter, and everything it leaves out is something the model may still key on.
The standard set, and what each one buys
- Random crop with padding, which teaches tolerance to position and framing.
- Horizontal flip, which doubles the data for free on anything without handedness.
- Colour jitter on brightness, contrast and saturation, for lighting.
- Random rotation of a few degrees, for camera tilt.
- Random erasing of a rectangle, which forces the model to use more than one part of the object.
Each is applied with a probability rather than always, so the model still sees clean examples and the distribution is widened rather than shifted.
Mixup, which breaks the rule deliberately
- , usually with between 0.2 and 0.4.
Mixup blends two images and blends their labels by the same weight, producing a training example that looks like nothing in the real world.
It works because it forces the model's output to move linearly between classes, which suppresses the overconfident regions a network otherwise invents between its training points.
CutMix pastes a rectangle of one image into another and weights the labels by the area, which keeps local statistics realistic while still mixing.
Both give a point or two on image classification and both make the model better calibrated, which is the less advertised half of the result.
Where it belongs in the pipeline
Augmentation applies to the training set only. Augmenting the validation set measures the model on a distribution it will never be asked about.
The exception is test time augmentation, where several transformed copies are averaged at inference to buy a small gain for times the cost.
Transformations are applied on the fly in the data loader rather than saved to disk, so every epoch sees a different sample and the storage cost is zero.
How to tell it has gone too far
Training loss above validation loss is the signature of augmentation that is too aggressive, since the model is being scored on distorted images and evaluated on clean ones.
A transformation that can destroy the label is worse than no augmentation, because it teaches the model that the wrong answer is sometimes correct.
Strong augmentation also needs longer training. Its whole effect is to make the problem harder, and a schedule tuned without it will stop before the gain arrives.