← Explainer Library

Interactive Explainer

Augmentation & Mixup

Twenty-four points is not much of a training set, and a classifier will draw a nervous, jagged boundary through the empty space between them. Two cheap tricks manufacture more data from what you already have: augmentation scatters plausible neighbors around each point, and mixup places soft-labeled points along the lines between points. Toggle each one and watch the boundary relax into a wide, confident margin.

Prelude

Two ways to invent training data

A model only ever sees the training points you give it; everywhere else it guesses. Both augmentation and mixup attack that emptiness by synthesizing new labeled examples — but they fill different geometry.

$$\tilde{x} = \lambda\,x_i + (1-\lambda)\,x_j, \qquad \tilde{y} = \lambda\,y_i + (1-\lambda)\,y_j, \qquad \lambda \in [0,1].$$

A point halfway between a blue example and an orange one is labeled “half blue, half orange.” Instead of clouds around points, mixup lays down a continuum of soft-labeled points along the segments between examples, teaching the model to change its prediction linearly and gently as you move from one class to the other.

The Lab

Fill in the manifold

Two classes, twelve points each, and a soft nearest-neighbor classifier whose decision landscape is painted underneath: blue where it predicts class A, orange for class B, and pale where it is unsure — that pale ribbon is the margin. Turn on augmentation and mixup and watch the synthesized points (small dots) reshape that landscape.

Decision landscape of the classifier. Big dots are the 24 real examples; small dots are synthesized examples. The dashed line is the highlighted mixup pair, and the ringed dot on it is $\tilde{x} = \lambda x_i + (1-\lambda)x_j$ colored by its soft label — drag $\lambda$ to slide it between the two classes.
The highlighted mixup point's soft label as $\lambda$ sweeps the segment: a linear blend from all–B to all–A.
Effective examples 24
Margin band (% area)
Boundary length
Start with both off. Note the boundary buckles toward isolated points and the pale margin is thin and uneven. Turn on Augmentation: each point sprouts a cloud, the support thickens, and the boundary straightens (its length drops). Now add Mixup: soft-labeled points bridge the gap and the pale margin band widens — the classifier is forced to transition gradually, which is exactly a larger margin.
The Payoff

Same goal, different geometry

Both methods are data-space regularizers: they don't touch the loss or the weights, they enlarge the region of input space the model is held accountable for. But they enlarge it differently, and that difference is the whole lesson.

In practice. Augmentation is domain-specific and nearly free lunch: flips, crops, color jitter for images; time-warps for audio; token dropout for text. Mixup is domain-agnostic — a few lines that blend a batch with a shuffled copy of itself — and it doubles as a calibration and label-noise-robustness trick. Stack them.