Skip to content
AI360Xpert
Beta

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. Teams with one deadline cannot afford thousands of proxy hours to find 25 subpolicies, and borrowed policies often mismatch the new domain anyway.

RandAugment removes the search and keeps the gains. Fix a pool of 1414 operations, pick NN uniformly per image, and apply each at global magnitude MM on a 00 to 1010 scale. Tuning NN and MM by short runs replaces searching thousands of combos. The family overview is image augmentation.

You need one idea first. Randomness with two knobs beats a searched recipe when budgets are tight.

Think of It Like This

A spice rack with two dials

You stop following 25 exact recipes and set two dials: how many spices per dish and how heavy each shake. Every dish differs, but the dials stay put for the week.

NN is the spice count, MM is the shake strength. Where the analogy stops: dishes tolerate any combo, while images do not, so MM needs a ceiling.

How It Actually Works

The two knobs

Pool holds 1414 ops: shear, translate, rotate, contrast, solarize, posterize and friends. For each image, sample NN ops uniformly with replacement and apply each at magnitude MM. Ordered pairs for N=2N = 2 total 142=19614^2 = 196 combos, plenty of variety from two integers.

A worked magnitude

Rotate max is 3030 degrees. At M=9M = 9:

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 ops near full strength, one possibly a 2727 degree turn. Common starts are N=2N = 2, M=9M = 9 for ImageNet scale and N=1N = 1, M=5M = 5 for small 32×3232 \times 32 photos.

Tuning order

Fix N=2N = 2, sweep MM from 44 to 1010 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.

Code

import random

def randaugment_ops(pool: list, n: int, seed: int = 0) -> list:    """Sample N ops uniformly. Magnitude M is applied later by each op."""    rng = random.Random(seed)  # fixed seed makes the demo repeatable    return [rng.choice(pool) for _ in range(n)]

pool = ["rotate", "contrast", "shear", "translate"] * 4  # 16 stand insprint(len(randaugment_ops(pool, 2)))  # -> 2

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 after RandAugment helps head classes. Cap MM near 55 on small images and verify with visual spot checks.

Stacking too many ops

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 only with evidence.

The Quick Version

  • RandAugment samples N operations per image at global magnitude M with no search.
  • N equals 2 from 14 ops gives 196 ordered pairs of variety from two knobs.
  • Magnitude 9 turns a 30 degree rotate into 27 degrees.
  • Start at N equals 2, sweep M first, and cap M on small or color critical images.