This is a worked-examples deep dive for the parent note on data augmentation — that parent note introduced the formulas for flips, crops, Mixup and CutMix; read it first if a formula here looks unfamiliar , because this page only applies those formulas to every kind of input you could meet: normal cases, edge cases, degenerate (broken) cases, a real-world word problem, and an exam-style twist.
Before any symbol appears, we recall it in one plain line so a newcomer can start from line one.
Definition The symbols we will reuse
x — an input image , thought of as a big grid of pixel numbers. When we blend two, we call them x A (image A) and x B (image B).
x ~ (x-tilde) — the new image built by mixing, e.g. x ~ = λ x A + ( 1 − λ ) x B (add the two pixel grids with weights).
y — the original label of an image: a list of numbers (one per class) saying which class it is. A pure cat is y = [ 1 , 0 ] .
label ( x ) — a plain-words function that reads off "which class is in image x ." So label ( a cat photo ) = cat . We use it to test whether a transform kept the meaning.
T or t — an augmentation function : a rule that takes an image and returns a transformed image, written T ( x ) or t ( x ) (parent-note notation for "apply the transform"). Example: t = "flip left-right."
λ (lambda) — a mixing weight , a number between 0 and 1 . Think of it as "what fraction of image A do we keep." λ = 1 means "all A"; λ = 0 means "all B."
y ~ (y-tilde) — the new label after mixing. A list of numbers (one per class) that add up to 1 ; each number is "how much of that class is in the picture."
ℓ — the loss (also called the training loss when averaged over the training set): a single number saying "how wrong the prediction is." Bigger = more wrong. Whenever we say "training loss" in words below, we mean the average of this ℓ .
If any of these feels shaky, the parent note builds them from scratch — this page assumes only these plain-word meanings.
Intuition Our label ordering (fixed for the whole page)
Every one-hot / soft label on this page is written [ index 0 , index 1 ] where index 0 = cat and index 1 = dog . So [ 1 , 0 ] = pure cat, [ 0 , 1 ] = pure dog. Class indices are arbitrary in general, so we pin them once here to avoid confusion.
Every augmentation problem falls into one of these cells . The worked examples below are each tagged with the cell they cover, and together they hit every row .
Cell
What makes it special
Covered by
A. Geometric — normal
crop/flip inside valid range
Ex 1
B. Geometric — degenerate
crop size = image size (zero freedom)
Ex 2
C. Sign/limit of λ
λ = 0 , λ = 1 endpoints
Ex 3
D. Mixup — interior λ
ordinary 0 < λ < 1 soft label
Ex 4
E. CutMix — area-based λ
label set by pixels , not chosen
Ex 5
F. Label-destroying transform
flip that breaks the class
Ex 6
G. Over-augmentation limit
strength → too high, off-distribution
Ex 7
H. Real-world word problem
pick a policy for a real dataset
Ex 8
I. Exam twist
Beta( α , α ) expectation
Ex 9
The columns "signs / zero / limits / word problem / twist" from the contract map to cells C, B, C, H, I respectively — none are skipped.
Worked example Ex 1 — how many distinct crops? (Cell A)
An image is 256 × 256 pixels. We take a random crop of size 224 × 224 .
How many distinct crops (by top-left corner) can we cut?
Forecast: guess before reading — is it in the hundreds, thousands, or millions?
Figure Ex 1: the outlined 256 × 256 image with one violet 224 × 224 crop inside it. Every magenta dot is a valid top-left corner; the orange double-arrow shows the 33 positions available along one edge. The picture makes the count concrete — we are literally counting dots.
Step 1 — Find the freedom in one direction.
The crop is 224 wide inside a 256 -wide image. The left edge can sit at column 0 , 1 , 2 , … up to the last spot where the crop still fits.
Why this step? A crop is fixed by where its top-left corner sits ; counting corners = counting crops.
Last valid left column = 256 − 224 = 32 . Including column 0 , that is 32 + 1 = 33 positions.
Step 2 — Both directions are independent.
The same 33 choices exist vertically.
Why this step? Horizontal and vertical shifts don't interfere — every left position pairs with every top position (a product , look at the grid of magenta corners in the figure).
crops = ( 256 − 224 + 1 ) 2 = 3 3 2 = 1089
Verify: units are "positions × positions = crops" ✓. Sanity: with a smaller crop we'd expect more freedom — try 200 : ( 256 − 200 + 1 ) 2 = 5 7 2 = 3249 > 1089 ✓ (bigger gap ⇒ more crops).
Worked example Ex 2 — the crop that isn't a crop (Cell B)
Same 256 × 256 image, but now the crop size is also 256 × 256 .
Forecast: how many distinct crops now?
Step 1 — Apply the same count formula.
( 256 − 256 + 1 ) 2 = 1 2 = 1
Why this step? We reuse Ex 1's logic — but notice the gap is zero , so the corner can only sit at ( 0 , 0 ) .
Step 2 — Interpret the degenerate answer.
One crop means no augmentation at all — the "crop" is the original image.
Why this step? Edge cases are where formulas quietly do nothing; you must recognize 1 as "identity transform," not a bug.
Step 3 — Push past the boundary to an invalid input.
Ask what the formula returns when the crop is larger than the image, e.g. 300 : ( 256 − 300 + 1 ) 2 = ( − 43 ) 2 = 1849 .
Why this step? The whole pedagogical point of a degenerate case is to learn where the tool silently lies : squaring turns a negative base (− 43 , meaning "the crop doesn't fit") into a happy-looking positive number. Knowing this is why real libraries raise an exception instead of trusting the formula — you must guard the input, not the output.
Verify: the formula never gives 0 or negative for a valid crop (size ≤ image ), since the minimum is ( 0 + 1 ) 2 = 1 ✓. The invalid 300 case gives a spurious 1849 despite no crop fitting — confirming the guard is necessary ✓. Degenerate and invalid inputs both caught ✓.
Worked example Ex 3 — the two endpoints of Mixup (Cell C)
Mixup blends class-0 image x A (cat) and class-1 image x B (dog). The blended image is x ~ = λ x A + ( 1 − λ ) x B and the blended label is
y ~ = λ [ 1 , 0 ] + ( 1 − λ ) [ 0 , 1 ] .
Work out both limits : λ = 1 and λ = 0 .
Forecast: what should each endpoint feel like physically?
Step 1 — Plug λ = 1 .
x ~ = 1 ⋅ x A + 0 ⋅ x B = x A , y ~ = 1 ⋅ [ 1 , 0 ] + 0 ⋅ [ 0 , 1 ] = [ 1 , 0 ] .
Why this step? Endpoints test whether the formula reduces to the un-augmented case. It does: the image is x A and the label is pure cat, a hard label.
Step 2 — Plug λ = 0 .
x ~ = 0 ⋅ x A + 1 ⋅ x B = x B , y ~ = 0 ⋅ [ 1 , 0 ] + 1 ⋅ [ 0 , 1 ] = [ 0 , 1 ] .
Why this step? The other endpoint gives pure dog — so Mixup smoothly interpolates between two ordinary training points; nothing weird happens at the boundary.
Verify: at both ends the label components still sum to 1 (1 + 0 = 1 , 0 + 1 = 1 ) ✓, and the image x ~ collapses to exactly x A or x B ✓ (recall x A , x B are the two input pixel grids, x ~ their weighted sum). Mixup contains "no augmentation" as its own boundary — reassuring.
Worked example Ex 4 — a soft label in the middle (Cell D)
λ = 0.4 , class 0 (cat) = [ 1 , 0 ] , class 1 (dog) = [ 0 , 1 ] . Find y ~ .
Forecast: since λ = 0.4 < 0.5 , which class should dominate the label?
Step 1 — Substitute directly.
y ~ = 0.4 [ 1 , 0 ] + 0.6 [ 0 , 1 ] = [ 0.4 , 0.6 ] .
Why this step? This is the raw Mixup rule; λ weights image A (cat), so 1 − λ = 0.6 weights image B (dog).
Step 2 — Read the meaning.
The target says "40% class 0 (cat), 60% class 1 (dog)." Class 1 dominates — matching our forecast because we kept less of image A.
Why this step? A soft label teaches the network calibration : don't scream "100% class 1" when the picture is genuinely a blend. This links to overfitting and generalization , the vault topic on why over-confident models generalize poorly — Mixup's soft targets are one cure.
Verify: 0.4 + 0.6 = 1 ✓ (valid probability vector). Symmetry check: swapping λ → 0.6 gives [ 0.6 , 0.4 ] , the mirror — consistent ✓.
Worked example Ex 5 — label from pixels, not choice (Cell E)
Paste a 96 × 96 patch of a dog onto a 192 × 192 cat . The label mixes proportional to patch area . Using our fixed ordering [ index 0 = cat , index 1 = dog ] , find y ~ .
A note on λ here (important): in Mixup (Ex 3–4) we chose λ as "fraction of image A kept." In CutMix, λ means something narrower — it is the fraction of pixels belonging to the base image (the cat) , and it is not free : the geometry of the pasted patch forces its value. Same letter, area-defined meaning. Keep the two straight.
Forecast: the dog patch is small-ish — is the cat share closer to 0.5 or 0.9 ?
Figure Ex 5: the magenta 192 × 192 cat image with a violet 96 × 96 dog patch pasted in the corner. The shaded dog rectangle is exactly one-quarter of the total area; the label [ 0.75 , 0.25 ] printed above shows the cat share is what's left. The figure lets you see that "half the side length" is only "a quarter of the area."
Step 1 — Compute the fraction of image that is dog.
dog fraction = 192 × 192 96 × 96 = 36864 9216 = 0.25.
Why this step? In CutMix the label weight λ is forced to equal how many pixels each class occupies (look at the shaded rectangle in the figure) — no free choice.
Step 2 — Cat share is the rest.
λ cat = 1 − 0.25 = 0.75 , y ~ = [ cat, index 0 0.75 , dog, index 1 0.25 ] .
Why this step? Supervision must match visible evidence: 75% of pixels are cat, so the label's index-0 (cat) entry is 0.75 and index-1 (dog) is 0.25 .
Verify: 0.75 + 0.25 = 1 ✓. Cross-check with the exact side ratio: ( 96/192 ) 2 = ( 0.5 ) 2 = 0.25 ✓ — the area ratio is the square of the length ratio, a good catch that stops "half the side ⇒ half the area" mistakes.
Worked example Ex 6 — when a flip is a lie (Cell F)
Let t be an augmentation function (recall: t ( x ) = "apply transform t to image x "). Take t = horizontal flip applied to a grayscale digit "6 " whose original label is y = "6" . Is the pair ( t ( x ) , y = "6" ) a valid training example?
The rule we must satisfy (restated in full so this example stands alone): a transform t is label-preserving only when applying it does not change which class the image belongs to — in symbols, label ( t ( x )) = label ( x ) , i.e. "the class-reading of the flipped image equals the class-reading of the original." Only then is ( t ( x ) , y ) a legal training pair.
Forecast: true or false — "a mirror never changes a label"?
Step 1 — Check the label-preserving condition.
We must verify label ( t ( x )) = label ( x ) for our specific t .
Why this step? Augmentation is only legal when it keeps the meaning. We must test the condition, not assume it.
Step 2 — Evaluate the specific transform.
A horizontally flipped "6 " is a mirror-image "6 " that no longer matches the canonical shape a digit classifier expects — the curl now opens the wrong way. In practice, digit datasets (MNIST etc.) forbid all flips because both horizontal and vertical mirrors produce glyphs that are no longer valid "6 "s (and a vertical flip infamously makes "6 " resemble "9 "). So label ( t ( x )) = label ( x ) — the condition fails .
Why this step? Whether a flip is safe depends on the domain ; for digits no flip is label-preserving, echoing the parent's "vertical flip breaks 6→9" warning and extending it honestly to the horizontal case too.
Verify: counterexample stands: feeding a flipped glyph labeled y = "6" injects a wrong pair, raising the training loss ℓ — the opposite of regularization. Contract case "degenerate/invalid input" handled ✓. This is the same reasoning that forbids flipping convolutional-network inputs for text or medical laterality — the CNN vault topic explains why such spatial models are sensitive to exactly these mirror symmetries.
Worked example Ex 7 — how strong is too strong? (Cell G)
Add Gaussian pixel noise with standard deviation σ to images whose pixels live in [ 0 , 1 ] . As σ → ∞ , what happens to training?
Forecast: does bigger σ always help generalization?
Step 1 — Small σ (e.g. 0.05 ).
The cat is still clearly a cat; the network learns noise-robust features → good regularization (the vault topic on penalizing complexity — augmentation is one flavor of it).
Why this step? We move along the strength axis from gentle to extreme to find where it breaks.
Step 2 — σ → ∞ (limiting case).
Pixels become pure random noise; every image looks the same regardless of class. The label y is now uncorrelated with the input.
Why this step? Limits expose failure modes: the "cat" and "dog" are indistinguishable, so the best the model can do is guess the class prior.
Step 3 — Consequence.
The training loss (the average of ℓ ) stops decreasing — it gets stuck near the entropy of the label distribution. This is the parent's "extreme augment ⇒ training loss stays high" made precise.
Verify (numeric): for a balanced 2-class problem, the best possible value of ℓ on pure-noise inputs is the entropy − 2 ⋅ 2 1 ln 2 1 = ln 2 ≈ 0.693 . Any augmentation pushing the training loss up toward 0.693 is destroying signal ✓. So "more is not always better" — off-distribution augmentation caps you at the guessing floor.
Worked example Ex 8 — designing a policy for chest X-rays (Cell H)
You train a convolutional network to detect pneumonia in chest X-rays . Available augments: horizontal flip, small rotation (± 10° ), brightness jitter, random erasing, Mixup. Which do you keep , and estimate the effective dataset multiplier.
Forecast: which single augment is dangerous here?
Step 1 — Filter by domain-true invariance.
Horizontal flip → reject : swaps left/right lung — the heart is on the left; flipping creates anatomically impossible, mislabeled scans (Cell F logic, label ( t ( x )) = label ( x ) ).
Small rotation, brightness → keep : patient positioning and X-ray exposure genuinely vary.
Random erasing → keep with care (mustn't erase the diagnostic region every time).
Mixup → optional; blending two X-rays is unphysical but can still regularize.
Why this step? Same rule every time: only invariances true in your domain survive.
Step 2 — Count only the augments with genuinely discrete, finite levels.
Suppose we discretize rotation into 5 visible settings and brightness into 4 levels. Independent choices multiply:
5 × 4 = 20 discrete variants per image .
Why this step? Independent augment axes combine by product , just like crop positions in Ex 1.
Step 3 — Handle the continuous augments (random erasing, Mixup) separately.
Random erasing (a rectangle at a random position/size) and Mixup (λ ∼ Beta , a continuous draw) do not have a clean finite level count — they produce effectively infinitely many variants. The honest way to report them is not as a number but as the word "unbounded (∞) ": we write the effective multiplier as "20 × discrete, times an unbounded continuous factor ." Interpretation: the 20 × is a floor you can actually count; the continuous augments multiply variety on top of it without a fixed ceiling, so you quote them as "∞ " rather than folding a fake integer into the product.
Why this step? Edge-case discipline: only augments with a genuine discrete alphabet belong in a finite product; continuous augments must be reported as unbounded, never disguised as a tidy integer.
Verify: with N = 2000 real scans, the countable effective size ≈ 2000 × 20 = 40 , 000 scans, and random-erasing + Mixup push effective variety toward ∞ on top of that ✓. Rejecting the flip removed a whole (wrong) factor, showing safety beats raw quantity — consistent with transfer learning (the vault topic on reusing models across domains), where domain mismatch is exactly the failure to watch for.
Worked example Ex 9 — expected Mixup weight (Cell I)
In Mixup, λ ∼ Beta ( α , α ) . Over many batches, what is the average value of λ ? Evaluate for α = 0.2 and interpret.
Forecast: with a symmetric Beta, guess the mean before computing.
Step 1 — Recall the Beta mean.
For λ ∼ Beta ( a , b ) the mean is a + b a . See Beta Distribution , the vault topic on this two-parameter distribution on [ 0 , 1 ] — exactly the range a mixing weight lives in, which is why Mixup uses it.
Why this step? The question asks an expectation , so we need the distribution's mean, not a single draw.
Step 2 — Substitute the symmetric case a = b = α .
E [ λ ] = α + α α = 2 1 .
Why this step? Symmetry (a = b ) forces the mean to the center 0.5 — independent of α . So on average Mixup blends the two images equally.
Step 3 — Interpret α = 0.2 (the twist).
The mean is 0.5 , but small α makes Beta U-shaped : most draws pile up near 0 or 1 (nearly-pure images), rarely a true 50/50 blend.
Why this step? Exam trap — "mean = 0.5 " does not mean "typical draw = 0.5 ." Small α ⇒ gentle augmentation (usually almost one image); large α ⇒ aggressive blending.
Verify: mean = 0.5 for any α > 0 ✓. Variance of Beta ( α , α ) is 4 ( 2 α + 1 ) 1 ; at α = 0.2 that is 4 ( 1.4 ) 1 ≈ 0.179 , close to the max possible 0.25 — confirming draws cluster at the edges (U-shape) ✓.
Recall Match the cell to the trap
Crop 224 from 256 — how many crops, and what breaks the formula? ::: 3 3 2 = 1089 ; it silently lies (returns a spurious positive after squaring a negative base) when crop size exceeds image size.
What is y ~ for λ = 0.4 , cat [ 1 , 0 ] and dog [ 0 , 1 ] ? ::: [ 0.4 , 0.6 ] (index 0 cat, index 1 dog).
CutMix, 9 6 2 dog patch on 19 2 2 cat — full label? ::: dog fraction 0.25 , so y ~ = [ 0.75 , 0.25 ] (cat, dog).
Why must you reject horizontal flip for chest X-rays? ::: It swaps left/right anatomy, so label ( t ( x )) = label ( x ) — a label-destroying transform.
Beta ( 0.2 , 0.2 ) — mean of λ , and why is the "typical" draw different? ::: Mean = 0.5 ; but small α makes it U-shaped, so most draws are near 0 or 1 , not 0.5 .
Mnemonic The scenario checklist:
"N-Z-L-W-T"
N ormal · Z ero/degenerate · L imit · W ord-problem · T wist.
"Never Zap Late Working Tigers." — run every new augmentation problem through all five before trusting your answer.