Skip to content
mlmentorship

Mixup and CutMix

Two data-augmentation schemes that train on convex combinations of pairs of inputs and their labels. Strong regularization for image classification; sometimes used in audio and tabular.

Published · 5 min read ·Core ·Foundation

Visual quick review

Visual first · depth when needed

Compare how Mixup and CutMix use the same 75/25 soft target while Mixup blends both examples at every input location and CutMix assigns the 25 percent contribution to a discrete patch occupying 4 of 16 equal cells.

Preparing the visual…

Summary

Mixup (Zhang et al., 2018) trains the model on convex combinations of pairs of training examples: and with . CutMix (Yun et al., 2019) instead pastes a rectangular patch from onto and mixes labels by the area ratio.

Both techniques regularize by training on examples between the original training points. Empirically:

  • Improve top-1 accuracy on ImageNet by ~1–2% over baseline.
  • Improve calibration (predicted probabilities track accuracy better).
  • Improve robustness to label noise and adversarial perturbations.
  • Standard in modern image classification recipes (timm, ConvNeXt, ViT-style training).

Less common in NLP (token mixing is non-trivial) and in pretraining (large data already covers the input space well). Sometimes used in audio (mix waveforms or spectrograms) and tabular (interpolate features).

Mechanism

Mixup

For each batch, sample once (or per sample) with small (typical 0.2–0.4). For paired examples and :

Train normally on with cross-entropy. The label is a soft target.

CutMix

Sample . Pick a random rectangle in of area (e.g., width and height times the image). Paste the corresponding region from into . Mix labels by the area ratio .

The resulting image has a clear local boundary (no blending). Models trained on CutMix often produce more localized class activations.

Learning objective

Match each input-mixing operation to the same weights in its soft target.

Mixup and CutMix input-target coupling with lambda equal to 0.75 Source A is represented by horizontal stripes and class label y A. Source B is represented by dots and class label y B. For Mixup, every input location contains 75 percent A and 25 percent B, and the soft target is 0.75 y A plus 0.25 y B. For CutMix, a 2 by 2 dotted B patch replaces part of a 4 by 4 striped A grid. Twelve of sixteen cells remain A and four of sixteen are B, so the realized retained-area lambda is 12 over 16, or 0.75, and the soft target is again 0.75 y A plus 0.25 y B. PAIRED SOURCES Alabel yA Blabel yB MIXUP · λ = 0.75blend every location A + B at every coordinate SOFT TARGET75% A25% B0.75 yA + 0.25 yB CUTMIX · REALIZED λ = 12/16 = 0.75replace a countable region 12 striped A cells4 dotted B cells AREA-MATCHED TARGET12/16 A4/16 Bλ = retained A area0.75 yA + 0.25 yBhard boundary · soft label input contribution = target contribution
Read it this way: keep the paired sources and target weights fixed. Mixup applies the 75/25 coefficient at every input coordinate. CutMix does no pixel blending: the dotted source B occupies 4 of 16 cells, so source A retains 12/16 of the area and receives 75% of the target. In real code, use the patch area that remains after image-boundary clipping. Original schematic checked against the Mixup paper, the CutMix paper, and the Torchvision guide.

Choosing

SettingMixup CutMix
ImageNet from scratch0.21.0
Small datasets0.2 (more aggressive Mixup hurts)1.0
ViT training0.2 + CutMix 1.0 (used together).

gives near-original samples (almost no mixing); gives (always equally mixed). between 0.2 and 1 is the empirical sweet spot.

Why it works (intuition)

  • Vicinal risk minimization (Chapelle et al., 2001): training on a vicinity around each point regularizes the decision boundary.
  • Empirically: smoother decision functions, better calibration, less overconfidence on out-of-distribution inputs.
  • Equivalent to an implicit form of weight regularization in the linear case.

Common pitfalls

  • Mixing labels but not inputs. Some implementations mix targets without mixing inputs; this is just label noise, not Mixup.
  • Combining with strong cropping. Mixup + RandomResizedCrop + label smoothing + AutoAugment is the modern recipe but can over-regularize small datasets.
  • Using on detection / segmentation directly. Class labels mix easily; bounding boxes do not. Variants like Mosaic (YOLOv4) handle this.
  • Forgetting to disable for evaluation. Eval should use clean images.