3.4.15 · D1Convolutional Neural Networks

Foundations — Data augmentation for images

2,672 words12 min readBack to topic

This page assumes nothing. Before you can read the parent note Data augmentation for images, you need to know what every letter and squiggle in it means. We build each one from a picture, then say why the topic needs it.


0. What is an image, really?

Before any formula, we must agree on what an "image" is to a computer.

Figure — Data augmentation for images

Look at the figure. On the left, a picture your eye reads as a shape. On the right, the exact same thing the computer sees: a grid of numbers. The whole topic is about doing arithmetic on this grid. When we "rotate a cat," we are really shuffling these numbers into new grid positions.

  • A number like 0 = black, 255 = brightest. This range is just "how many brightness levels a byte can hold."
  • The grid has a height and a width — how many rows and columns of pixels.

1. The size symbols: , ,

Figure — Data augmentation for images

The picture: a colour photo is really three stacked grids — one for Red, one for Green, one for Blue. Here . A grey photo has . Stack the three grids and you get a box of numbers that is tall, wide, and deep.

Why the topic needs it: the parent note writes a transformation as We now decode this piece by piece below — but you already know just means "a box of numbers this big."

Recall What does

mean? Three numbers per pixel — Red, Green, Blue ::: yes, the image is three stacked grids.


2. The set symbols: , , , ,

These come from the language of maths, not from images — but each has a plain meaning.


3. Coordinates: , their domain, primes , and the center

Figure — Data augmentation for images

Why the topic needs it: every geometric augmentation is just a rule that says "the pixel at moves to ." Because addresses run , the horizontal flip that mirrors left-to-right must send column to column , column to , and so on. The rule that does this is:

Check it: with zero-based indices the smallest address is and the largest is ; plugging gives (leftmost becomes rightmost) — exactly a mirror. The is entirely because we count from 0. The vertical flip is the same idea turned on its side, mirroring top-to-bottom.

The center


4. Angle , its units, and the full rotation formula

Why and , not something else? Because rotation is circular motion, and , are exactly the horizontal and vertical positions of a point on a circle after turning by . They are the only tools that convert "spin by an angle" into ordinary multiply-and-add.

  • = how much of the turn stays in the horizontal direction.
  • = how much leaks into the vertical direction.
  • At : , → the point doesn't move (correct — no rotation).
  • At (a quarter-turn): , → right becomes up.

That is exactly the matrix formula in the parent note, written out number-by-number so you can hand-compute it. Why subtract first? Rotation formulas only work around the origin ; subtracting the center moves the pin to the origin, and adding it back afterwards slides everything home.

Landing between pixels: interpolation


5. Probability words: , , , , distributions

The parent's "Mathematical Framework" uses probability. Here is the minimum.

The gap between (few photos) and (the real world) is exactly overfitting — see 5.2.3-Overfitting-vs-underfitting. Augmentation shrinks that gap by faking extra samples.


6. Loss , the model , and (again!)

Why the topic needs it: augmentation changes the input into but keeps the label . So training minimizes — "be right even on the wobbled version." This is what drives the model toward invariances and better generalization.


7. How these foundations feed the topic

Image = grid of numbers

Sizes H W C

Pixel address x y from 0 to W minus 1

Transform machine t maps box to box

Rotation uses angle theta with sin cos

Flip uses W minus 1 minus x

Interpolation fills fractional pixels

Probability sim E lambda Beta

Random augmentation each epoch

Data Augmentation

Loss and model f theta

Better generalization less overfitting

Each box on the left is a prerequisite; follow the arrows and you arrive at the parent topic. Related regularizers that share this goal include 3.4.8-Dropout-in-neural-networks and, for reusing pretrained features, 3.4.12-Transfer-learning-CNs.


Equipment checklist

Test yourself — reveal only after you answer aloud.

An image is fundamentally…
a grid of numbers (pixels), one number per channel per position.
means…
height (rows) by width (columns) by channels (numbers per pixel).
stands for…
the real numbers — any value on the number line.
reads as…
" is a machine turning an into a ."
A set differs from a bag/multiset because…
a set holds only distinct items (no duplicates).
What is ?
the set (toolbox) of all allowed augmentation machines ; picks one at random.
The domain of is…
whole numbers (zero-based indexing).
Horizontal flip formula…
, .
Vertical flip formula…
, .
Center coordinates…
, ; may fall between pixels when or is even.
Full rotation of about center…
.
's units for
radians ().
Why is interpolation needed after rotation?
rotated addresses are fractional; interpolation (nearest-neighbor or bilinear) picks the output pixel colour.
is…
a distribution on , symmetric about 0.5; small → near 0/1 (little mixing), large → near 0.5 (strong mixing).
means…
the average over all the randomness.
vs
the few photos we have vs. the huge unseen real-world distribution; their gap is overfitting.
The loss measures…
how wrong the prediction is versus the true label .