Exercises — Data augmentation strategies
Before we start, one convention we will reuse everywhere, defined once so no symbol is used unearned:
Level 1 — Recognition
Exercise 1.1 (L1)
Which of these transforms is label-preserving for a photo of a cat, and which is not? (a) horizontal flip, (b) brightness, (c) rotating the image upside-down (180°) if the label is "which way is up", (d) random crop keeping the cat visible.
Recall Solution 1.1
Label-preserving = the correct answer must not change after the transform.
- (a) Horizontal flip — preserving. A mirror-image cat is still a cat.
- (b) Brightness — preserving. A brighter cat is still a cat.
- (c) 180° rotation when the task is "which way is up" — NOT preserving. You literally changed the up/down answer.
- (d) Random crop that keeps the cat visible — preserving. Key idea: "label-preserving" is relative to the task, not to the pixels. (c) shows the same rotation can be safe or unsafe depending on what means.
Exercise 1.2 (L1)
State the two mental models for why augmentation helps, in one line each.
Recall Solution 1.2
Model 1 — more data: every transform is a free new training example, so the model effectively sees far more variety. Model 2 — injecting invariances: you tell the network which changes must not change the answer, which shrinks the set of functions it can fit — this is exactly Regularization and fights overfitting.
Level 2 — Application
Exercise 2.1 (L2) — counting crops
An image is . You take a random crop of size . How many distinct top-left corner positions (hence distinct crops) are possible?
Recall Solution 2.1
The top-left corner's row can start at , giving choices. Same for the column. Why it helps: the cat now appears at different positions, so a CNN cannot cheat by memorizing an absolute location — it learns translation-tolerant features.
Exercise 2.2 (L2) — Mixup label
Mixup blends image A = cat and image B = dog with (so of A survives). Compute the mixed label .
Recall Solution 2.2
The rule is . Why: the target says "40% cat, 60% dog." The network is pushed toward a calibrated soft output rather than an over-confident hard .
Exercise 2.3 (L2) — CutMix area ratio
You paste an patch of a dog onto a cat. CutMix sets the cat's label weight to . Compute the mixed label.

Recall Solution 2.3
Patch area . Total area . So the label is (cat, dog). Why area, not a fixed value? The label should match how much of each object is actually visible. of the frame is dog, so dog supervision.
Level 3 — Analysis
Exercise 3.1 (L3) — unbiasedness of one-sample augmentation
The parent note claims: sampling one transform per example per epoch gives an unbiased estimate of the expected augmented loss. Prove it. Define "unbiased" first.
Recall Solution 3.1
Definition earned: an estimator is unbiased for a target if — on average across all randomness, it lands exactly on the true value (no systematic drift). Target (the thing we wish we could compute for one example ): Estimator we actually use: draw one and report . Proof: take the expectation of the estimator over the same draw: The expectation of a single sample from is the expectation over — that's the definition of . Averaging over the examples keeps it unbiased (expectation of a sum = sum of expectations). Hence plain SGD on the one-sample loss chases the right target. Connects to Empirical Risk Minimization.
Exercise 3.2 (L3) — why precomputing breaks it
Suppose you precompute one fixed augmented copy of each image and reuse it every epoch. Using the estimator language of 3.1, explain precisely what goes wrong.
Recall Solution 3.2
If is drawn once and then frozen, every epoch reuses the same . The randomness is gone: across epochs you are no longer averaging over , you are minimizing loss on a fixed enlarged dataset of size with one arbitrary transform each. Consequences: (1) you lose the per-epoch novelty, so memorization becomes possible again; (2) your effective target quietly changes from to a single random point , which is a biased proxy for the neighbourhood average. Fix: sample a fresh every epoch (on-the-fly augmentation).
Exercise 3.3 (L3) — expected Mixup weight
In Mixup, . Using the fact that a $\text{Beta}(a,b)$ has mean , find for any . What does this say about the average blend?
Recall Solution 3.3
With : Interpretation: on average the two images are blended 50/50, regardless of . The parameter only controls the spread: small pushes toward or (nearly clean images, mild mixing), large concentrates near (aggressive half-and-half blends). See the shape in the figure.

Level 4 — Synthesis
Exercise 4.1 (L4) — design a policy for a medical X-ray classifier
You classify chest X-rays as "healthy" vs "pneumonia". Choose which of these to include and justify each: horizontal flip, small rotation (), brightness/contrast jitter, vertical flip, random erasing of a small square.
Recall Solution 4.1
- Horizontal flip — REJECT (usually). Left vs right laterality matters in chest imaging; a flip can swap heart/organ sides and mislead. Only use if your task is truly side-invariant.
- Small rotation — ACCEPT. Patients aren't perfectly aligned; mild rotation is realistic and label-preserving.
- Brightness/contrast jitter — ACCEPT. Different machines/exposures produce different intensities; this injects sensor invariance.
- Vertical flip — REJECT. An upside-down chest is off the true data distribution; the network wastes capacity on impossible images.
- Random erasing (small) — ACCEPT with care. Forces use of the whole lung field, not one lucky patch (like Dropout but in pixel space). Keep the square small so it rarely hides the actual lesion. Guiding principle: include a transform iff its invariance is true in the medical domain and the result stays on the real data distribution.
Exercise 4.2 (L4) — combine augmentation with normalization
You use random brightness jitter and Batch Normalization. A teammate says "BatchNorm already normalizes intensities, so brightness jitter is redundant." Argue for or against.
Recall Solution 4.2
Against the claim — they do different jobs. BatchNorm rescales activations to zero-mean/unit-variance per batch; it does not teach the network that a dark cat and a bright cat are the same class. Brightness jitter varies the input so the network learns features robust to lighting before normalization. BatchNorm stabilizes optimization; jitter injects an invariance. They are complementary: keep both. (If anything, augmentation makes each batch more diverse, which slightly changes BatchNorm's running statistics — usually beneficial.)
Level 5 — Mastery
Exercise 5.1 (L5) — expected label under random CutMix
You apply CutMix with a square patch whose side length is drawn uniformly from pixels, pasted onto a image. The pasted-object label weight is . Find the expected dog-label weight .
Recall Solution 5.1
We need where is uniform over the integers . Use with : So . Then Interpretation: on average about 33.5% of the label mass goes to the pasted object under this policy — a strong mixing pressure, useful only if that matches how much foreground you want to swap.
Exercise 5.2 (L5) — is Mixup's label-mixing consistent with ERM's expectation?
Mixup replaces by with random . Show that if the loss is linear in the label (as cross-entropy against a soft target is, per component), then training on Mixup targets equals training on an expected loss — connecting it back to the augmented-ERM story.
Recall Solution 5.2
Cross-entropy against a soft target is , which is linear in each . Substitute : So the mixed-label loss is a convex combination of the two clean-label losses with weights . Taking the expectation over (mean from 3.3) shows the network is trained to behave linearly between classes — smoother decision boundaries. This mirrors the augmented-ERM view: we minimize an expectation over a random transform (here the transform is "blend with a random partner at strength "). Same ERM machinery, richer .
Active recall
Related deep material: Transfer Learning (another way to inject prior knowledge when data is scarce) and the Hinglish companion 3.2.13 Data augmentation strategies (Hinglish).