Convolutional Neural Networks
CSC3104 · Lab

Convolution arithmetic

Compute conv output shapes and parameter counts like the exam asks, then paint an image and watch an edge detector light up — parameter sharing you can see.

  1. 1 · Predict0/1
  2. 2 · Experiment0/2
  3. 3 · Explain0/1
  4. 4 · Code it0/2
  5. 5 · Challenge
  6. 0/4 tasks done

Predict first

Commit to a guess before you touch anything. Being wrong here is how it sticks.

W = 32, K = 5, P = 0, S = 1. Output width?

Experiment

Move the controls and watch the outputs. Goals tick off automatically when you reach them.

Output size & parameters

Output tensor
224 × 224 × 64
⌊(224 − 3 + 2·1) / 1⌋ + 1 = 224
Parameters
1,792
Multiply-adds
86,704,128

(3·3·3 + 1) · 64 — independent of image size, thanks to parameter sharing.

Kernel playground

input — paint with your mouse/finger
output
weights
-101
-202
-101

The same 9 weights slide over every position — that's why a conv layer works anywhere in the image (translation equivariance).

Explain it

Put what you saw into words. This is what the exam will ask you to do.

Why do CNNs beat fully connected networks on images? Name the two inductive biases and what pooling adds.

Code it

Write real code against real data. Python and SQL run right here in your browser and hidden tests check your work; the AI reviews it like an examiner.

Pythonwarm-up

Shapes and parameter counts

Write conv_out(w, k, p=0, s=1) → output width ⌊(w − k + 2p) / s⌋ + 1, and conv_params(k, c_in, c_out, bias=True) → (k·k·c_in + 1)·c_out (no +1 without bias). Then use them to print the shapes and parameters of: 64×64×3 → conv3×3(32, p=1) → maxpool 2×2 → conv3×3(64, p=0).

Ctrl/⌘ + Enter to run

Challenge

Fixed variations, a new problem every day, and unlimited AI challenges built from your current settings.

ResNet Stem Spatial Output

ResNet's first layer: input 224×224, kernel 7×7, padding 3, stride 2. What is the output spatial width?