ResNet for image classification
Skip connections make 100+ layer CNNs trainable. Backbone of much of pre-ViT computer vision.
import torchvision.models as M
net = M.resnet50(weights='IMAGENET1K_V2')Name things for the reader, not the writer.
Name things for the reader, not the writer.
Deep Learning Building Blocks
A convolution slides a learnable filter mathbf{K} in mathbb{R}^{k_h times k_w} across an input feature map and outputs, at each spatial position, the dot product between the filter and the local patch. For an image of shape (C_{in}, H, W) and C_{out} filters each of shape (C_{in}, k_h, k_w), the lay
Convolutions = learnable filters sliding over a tensor with shared weights.
A convolution slides a learnable filter across an input feature map and outputs, at each spatial position, the dot product between the filter and the local patch. For an image of shape and filters each of shape , the layer produces an output of shape where depends on padding and stride .
Convolutions encode three powerful inductive biases: locality (each output depends on a small input neighborhood), translation equivariance (shifting the input shifts the output by the same amount), and weight sharing (the same filter is reused across every position, drastically reducing parameter count compared to a fully connected layer).
Receptive field is the region of the input that influences a given output unit. It grows linearly with depth in vanilla CNNs and exponentially with dilation. Modern architectures (U-Net, EfficientNet) carefully manage receptive field to balance local detail and global context.
Python (in browser)
Expected: Non-zero where there's a vertical brightness change.
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
Most CNN computation cost concentrates in the convolutions — roughly multiplies per layer. Depthwise-separable convolutions (MobileNet, EfficientNet) decompose this into a depthwise spatial conv + a 1×1 pointwise conv, slashing cost by roughly .
Skip connections make 100+ layer CNNs trainable. Backbone of much of pre-ViT computer vision.
import torchvision.models as M
net = M.resnet50(weights='IMAGENET1K_V2')Encoder-decoder with skip connections — the default architecture for medical image segmentation, denoising, and diffusion model backbones.
Depthwise-separable convolutions cut compute 8–9× with minimal accuracy loss. The default for on-device inference.
Put your understanding to the test. Score + streak + speed all count.
3 quick questions. Get 2 right to mark this lesson complete.