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 · 9 min read ·Core ·Foundation
Reading depth

Summary

Mixup blends paired inputs and class targets with the same coefficient; CutMix replaces a region and uses realized-area target weights. The constructions impose training conventions on synthetic inputs, not a guarantee that semantic evidence is proportional to those coefficients. Quality, calibration, and robustness effects require evaluation under the actual task and recipe.

Mechanism

Mixup

For paired same-shaped numeric inputs and class-probability targets, choose :

With , , labels A/B, and , the input becomes . The target is , a nonnegative distribution summing to one. At illustrative mixed-input prediction , soft-target cross-entropy is:

The weighted class losses must use this same mixed-input prediction, not predictions on the two original inputs. For a batch, preserve the example permutation and align every input/target coefficient; declare per-batch or per-example sampling.

CutMix

Let binary M equal one on retained A pixels and zero on the pasted B region:

Broadcast the spatial mask across image channels. The pictured four-cell patch in a grid gives and the same target as above. The actual synthetic input differs: pasted regions are not pixelwise blends.

Learning objective

The realized patch area determines the mixed target weights

The realized patch area determines the target mixtureThe sampled patch extends beyond the image. Clipping leaves 30 of 100 pixels. Its target weight is 0.3. The retained base contributes 0.7.The target follows the realizedclipped areaSampled 7 x 6; realized 5 x 630 inserted pixels / 100 = 0.3
Derivation
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
Mixup blends every coordinate using 75/25 coefficients. CutMix pastes four of sixteen cells, leaving twelve A cells. Both targets are 75/25 here, although the inputs differ. Original schematic follows the Mixup paper, CutMix paper, and Torchvision guide.
Check: Why must the CutMix target use the realized 12-of-16 retained cells rather than an unadjusted requested patch coefficient?
Read it this way: The sampled patch extends beyond the image. Clipping leaves 30 of 100 pixels. Its target weight is 0.3. The retained base contributes 0.7.
Should the target use the sampled 42 pixels or the realized 30?

Change the Interpolation Coefficient

New task: Set lambda to one-half for the same paired vectors.

Picture and change: Change both input and target: and .

Check: Holding the illustrative prediction at gives loss . The actual model’s new prediction can differ; retaining the old target would mismatch the specified construction.

Use when: The sampled coefficient changes; alpha controls its distribution, not a deterministic mixing result.

Clip a Boundary-Crossing Rectangle

New task: A requested patch leaves only inside the image.

Picture and change: Use half-open coordinates, clip ordered rectangle bounds to the image, and count actual replaced pixels. For and , clipped width is one and height two.

Check: Two inserted cells give and target , not .

Use when: Boundaries or integer rounding change realized area. An area-weighted target is still a convention: that small patch could remove the only visible A object.

Choosing

For with positive alpha, the mean is one-half and variance is . Small alpha favors endpoints; large alpha concentrates near one-half. The original Mixup and CutMix papers report recipe-specific experiments, not universal improvement magnitudes.

Why it works (intuition)

Vicinal risk minimization motivates training on chosen neighborhoods around examples. Those neighborhoods encode assumptions; synthetic points need not belong to the deployment distribution or preserve its correct labels.

Common pitfalls

  • Label-only mixing: it is not the stated paired-input augmentation, whatever separate objective it implements.
  • Wrong target unit: image classification, segmentation, boxes, and sequences require task-specific target handling.
  • Evaluation contamination: disable random training mixing for ordinary clean-example evaluation.
  • Recipe interactions: augmentation and target smoothing can jointly overregularize; evaluate matched ablations.