1. An image is numbers

A picture is a grid of numbers — three grids, one each for red, green and blue.

Why? ▸
  • Why three grids? A colour pixel is three numbers — how much red, green and blue. So a 12×12 colour image is really three 12×12 grids stacked: the channels. Grayscale images (like MNIST later) have one.

  • Why divide by 255? Networks train more easily on small numbers. 0–255 becomes 0–1; nothing else changes.

img = Image.open("seven.png").convert("RGB")
x = transforms.ToTensor()(img)   # [3,12,12], 0..1
x = x.unsqueeze(0)               # [1,3,12,12]

PyTorch [1,3,12,12] (N,C,H,W) · TF [1,12,12,3] (N,H,W,C)

x ∈ ℝ^{3×12×12}, values scaled to 0–1