Skip to content
AI360XpertBeta

RandAugment Augmentation

Skip the search. Pick N random operations at strength M for every image. Two knobs replace a thousand GPU hour policy hunt.

RandAugment samples 2 operations from 14 at magnitude 9, so a 30-degree rotate becomes 27 degrees with no search.
RandAugment samples 2 operations from 14 at magnitude 9, so a 30-degree rotate becomes 27 degrees with no search.

Why Does This Exist?

AutoAugment works, but its search costs more than many final runs: thousands of proxy hours to discover 25 subpolicies, and borrowed policies often mismatch the new domain anyway. Teams with one deadline can't afford that hunt for every dataset.

RandAugment (Cubuk et al., 2020) removes the search and keeps the gains. Fix a pool of 14 operations, pick NN uniformly per image, and apply each at global magnitude MM on a 0 to 10 scale, where NN counts the operations and MM sets their strength. Tuning two integers by short runs replaces searching thousands of combos. The family overview lives in image augmentation, and the mixing methods it pairs with are MixUp and CutMix.

Think of It Like This

A spice rack with two dials

You stop following 25 exact recipes and set two dials instead: how many spices per dish and how heavy each shake. Every dish comes out different, but the dials stay put all week and dinner still improves.

NN is the spice count and MM is the shake strength. It stops where taste stops: dinner guests tolerate any combo, while a classifier chokes when strong transforms erase the subject, so MM needs a ceiling your tongue never did.

How It Actually Works

The pool holds 14 operations: rotate, shear, translate, contrast, solarize, posterize, color, brightness, and friends. For each image, sample NN operations uniformly with replacement and apply each at magnitude MM. Ordered pairs for N=2N = 2 total 142=19614^2 = 196 combos, so two integers buy plenty of variety.

Worked magnitude: rotate at M = 9

Rotate peaks at 30 degrees, and each operation scales linearly with MM out of 10:

angle=M/10×30=0.9×30=27\text{angle} = M / 10 \times 30 = 0.9 \times 30 = 27

So N=2N = 2, M=9M = 9 applies two random operations near full strength, one possibly a 27-degree turn. Common starts are N=2N = 2, M=9M = 9 at ImageNet scale and N=1N = 1, M=5M = 5 on small 32×3232 \times 32 photos, which tolerate less distortion.

Tuning order

Fix N=2N = 2, sweep MM from 4 to 10 on short runs, then try N=1N = 1 and 33 at the best MM. Larger images tolerate larger MM. Keep color-critical tasks at modest MM because strong posterize erases tints the label depends on.

Code

import random
POOL = [    "autocontrast", "equalize", "rotate", "solarize", "color",    "posterize", "contrast", "brightness", "sharpness", "shear-x",    "shear-y", "translate-x", "translate-y", "cutout",]

def randaugment_ops(n: int, seed: int = 7) -> list:    """Sample N ops uniformly; each op later applies global magnitude M."""    rng = random.Random(seed)  # fixed seed makes the demo repeatable    return [rng.choice(POOL) for _ in range(n)]

print(randaugment_ops(2))# -> ['posterize', 'rotate']print(len(POOL), len(POOL) ** 2)# -> 14 196

Seed 7 draws posterize then rotate, one of 196 ordered pairs from the 14-operation pool.

Watch Out For

Magnitude that deletes the subject

M=10M = 10 shear or large translate can push a small bird fully out of frame while keeping its tag. The symptom is tail classes collapsing even as RandAugment helps head classes. Cap MM near 5 on small images and verify with visual spot checks before long runs.

Stacking too many operations

N=3N = 3 at high MM compounds distortions until images leave the natural manifold. Training loss looks regularized while clean validation stalls. Start at N=2N = 2 and raise it only with evidence.

The Quick Version

  • RandAugment samples N operations per image at global magnitude M with no search.
  • N equals 2 from 14 operations gives 196 ordered pairs of variety from two knobs.
  • Magnitude 9 turns a 30-degree rotate into 27 degrees.
  • Fix N at 2 first, sweep M, then try neighboring N values.
  • Cap M on small or color-critical images so transforms never erase the subject.