Foundations to Frontier
Tests
E. Deep Learning › E4 Regularization Techniques (one page each)

Cutout and CutMix

Cutout blanks a random square of each training image; CutMix instead pastes in a square from another training image and mixes the two labels in proportion to the pasted area. Both force a network to recognise objects from partial evidence rather than one most-telling region, which improves robustness to occlusion and, for CutMix, localisation. This page covers both, how CutMix sets its label weights, how they compare with mixup, and how they are used in modern recipes. In the exercises you check that CutMix's label always matches the visible area, then train on small shape images and find that Cutout and CutMix gave up 1.5–3 points of clean accuracy but made the network far more robust when part of the shape was hidden, while mixup hurt.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Hide part of the picture

A network shown whole pictures can get away with looking at only one telling part, such as a bird’s beak. If that part is hidden at test time, by a branch or a shadow, it fails. Cutout hides a random square of every training image, so the network must use the rest. CutMix goes further: it fills the square with a patch of another image and labels the result by how much of each image is visible.

Structured masking: what gets removed, and can it be recovered?
+→
training label: 86% A, 14% B
Feature maps of images are smooth, so a single dropped value is almost determined by its neighbours and the next convolution can fill it in: element-wise dropout removes little information. Dropping whole channels (spatial dropout) or contiguous blocks (DropBlock) removes information the network cannot interpolate. Cutout erases a patch of the input; CutMix pastes in a patch of another image and mixes the labels by area; mixup blends whole images and labels.
Why engineers care

Real perception inputs are often partly hidden: pedestrians behind cars, runways behind cloud, parts behind fixtures. Training with occlusion-style augmentation improves robustness to these cases at almost no cost, and CutMix is a standard part of image-classification recipes.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Cutout…
  2. 2. CutMix's label is mixed by…
  3. 3. These augmentations mainly improve robustness to…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Cutout: choose a centre at random and set a square of side s to zero (or the mean). The label is unchanged.
  • CutMix:
    1. draw λ ~ Beta(α, α) (usually α = 1);
    2. choose a box of area (1 − λ)·h·w, side √((1 − λ)hw) for a square;
    3. copy that region from another image;
    4. set the label to λ_actual·yₐ + (1 − λ_actual)·y_b, where λ_actual = 1 − box area/(hw) after clipping the box to the image.
  • Examples:
    • a 16 × 16 box in a 32 × 32 image gives λ = 0.75;
    • a 112 × 56 box in 224 × 224 gives 0.875;
    • for λ = 0.75 in 32 × 32, the square side is 16.
  • Compared with mixup: mixup blends every pixel and produces unnatural ghost images; CutMix keeps every pixel natural and only mixes which object fills which part.
📝 Quick check (Level 1)
0/3 answered
  1. 1. λ for a 16 × 16 box in 32 × 32:
  2. 2. Cutout changes the label…
  3. 3. CutMix's images, unlike mixup's, have…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Cutout and CutMix in code

Exercise 1. CutMix with a target λ of 0.75 on a 32 × 32 image pasted exactly 25% of the other image and set the label to (0.75, 0.25), matching the visible fraction; Cutout blanked exactly 64 pixels for an 8 × 8 patch.

Practice.

  • Cutout with a patch about half the image side worked well on CIFAR-10 (16 × 16 on 32 × 32). Random erasing (Zhong et al., 2020) varies size, aspect ratio and fill.
  • CutMix with α = 1, applied with probability 0.5–1 per batch, often alternated with mixup (timm’s Mixup(mixup_alpha=0.8, cutmix_alpha=1.0)).
  • Compute λ from the actual clipped box.
  • For detection and segmentation, copy-paste augmentation pastes whole object instances with their masks.
from timm.data import Mixup
mix = Mixup(mixup_alpha=0.8, cutmix_alpha=1.0, prob=1.0, switch_prob=0.5, label_smoothing=0.1, num_classes=1000)
x, y_soft = mix(x, y)
🐍 Exercise 1: CutMix labels follow the area
Implement CutMix for a pair of images and Cutout, and check that CutMix's label equals the visible fraction of each image.
📝 Quick check (Level 2)
0/3 answered
  1. 1. CutMix's λ should be computed from…
  2. 2. Random erasing varies…
  3. 3. Copy-paste augmentation pastes…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Using all the evidence. Without occlusion augmentation, a network can minimise its loss using the single most discriminative region. Removing a random region at training time makes any one region unreliable, so it must spread its reliance over the object. Class activation maps of CutMix-trained networks cover objects more fully, and their localisation improves (Yun et al., 2019).

Cutout as structured input dropout. Cutout is dropout on the input with a spatially contiguous mask, the input-level analogue of DropBlock (E4-4). Contiguity matters because, as with feature maps, pixels are correlated.

CutMix as a vicinal distribution. Like mixup it trains on combinations of examples with matching combinations of labels. Its mixing is spatial rather than pixel-wise, so its inputs stay on the manifold of natural image patches.

Costs. Erasing can delete the whole object in small images, creating mislabelled examples; this is why patch sizes are tuned and why clean accuracy can drop a little, as in exercise 2.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Cutout is the input-level analogue of…
  2. 2. CutMix improved which ability besides accuracy?
  3. 3. A risk of large erased patches is…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Robustness to occlusion

History.

  • T. DeVries and G. Taylor (2017) introduced Cutout; Z. Zhong et al. (2020) random erasing.
  • S. Yun et al. (2019) introduced CutMix.
  • G. Ghiasi et al. (2021) introduced copy-paste augmentation for instance segmentation.
  • DeiT (2021) and later recipes combined CutMix, mixup and RandAugment.

Exercise 2. 12 × 12 images of a hollow square or a plus sign of random size and position with noise. An MLP (144 → 64 → 2) trained with Adam for 1000 mini-batch steps on 200 images, tested on 1000 clean images and on the same images with a random 5 × 5 patch blanked. Means of three seeds:

augmentation clean accuracy accuracy with a patch blanked drop
none 0.950 0.885 0.065
Cutout (5 × 5) 0.920 0.907 0.013
CutMix (5 × 5) 0.934 0.900 0.034
mixup (α = 1) 0.882 0.837 0.045
  • Without augmentation the network was best on clean images but lost 6.5 points under occlusion.
  • Cutout and CutMix traded 1.5–3 points of clean accuracy for robustness. They gave the best occluded accuracy, and Cutout nearly removed the occlusion penalty.
  • Mixup hurt both on this small problem: blending whole images of thin shapes produced ambiguous inputs.
  • Lesson: occlusion-style augmentation buys robustness when occlusion is expected at test time; measure both clean and occluded performance before choosing.
🐍 Exercise 2 (research): robustness to occlusion
Train on small shape images with no augmentation, Cutout, CutMix and mixup, and compare clean accuracy with accuracy when a patch is blanked.

Cutout and CutMix in AI, robotics and aerospace

  • Pedestrian and vehicle detection must handle heavy occlusion; erasing and copy-paste augmentations are standard there.
  • Aerial and satellite imagery: clouds and shadows hide parts of scenes; occlusion augmentation improves robustness.
  • Industrial inspection: parts are partly hidden by fixtures or tools; Cutout-style training helps classifiers use all visible evidence.

References

  1. T. DeVries, G. W. Taylor (2017). “Improved regularization of convolutional neural networks with Cutout.” arXiv:1708.04552.
  2. S. Yun, D. Han, S. J. Oh, S. Chun, J. Choe, Y. Yoo (2019). “CutMix: regularization strategy to train strong classifiers with localizable features.” Proc. ICCV.
  3. Z. Zhong, L. Zheng, G. Kang, S. Li, Y. Yang (2020). “Random erasing data augmentation.” Proc. AAAI.
  4. G. Ghiasi et al. (2021). “Simple copy-paste is a strong data augmentation method for instance segmentation.” Proc. CVPR.