Skip to content
← All PyTorch tracks

CNNs from Scratch

PyTorch

Build convolutional networks one block at a time — from raw conv to skip connections and squeeze-excitation.

15 exercises

Explore freely. Sign in to keep your progress.

Your learning sequence

  1. 1 Not solved yet. Implement 1D Convolution Practice · Hard
  2. 2 Not solved yet. Implement Conv2d Practice · Medium
  3. 3 Not solved yet. Implement Max Pooling 1D Practice · Medium
  4. 4 Not solved yet. Implement Average Pooling 1D Practice · Medium
  5. 5 Not solved yet. Depthwise Separable Convolution Practice · Hard
  6. 6 Not solved yet. Transposed Conv2d Practice · Hard
  7. 7 Not solved yet. Skip Connection Block Practice · Medium
  8. 8 Not solved yet. Squeeze-and-Excitation Block Practice · Medium
  9. 9 Not solved yet. Simple CNN Practice · Medium
  10. 10 Not solved yet. Train Image Classifier End-to-End Practice · Medium
  11. 11 Not solved yet. Patch Embedding with CLS Token Practice · Medium
  12. 12 Not solved yet. ViT Encoder Block Practice · Medium
  13. 13 Not solved yet. ViT Classification Forward Practice · Hard
  14. 14 Not solved yet. Train ViT Classifier End-to-End Practice · Hard
  15. 15 Not solved yet. ViT with Mixup Augmentation Practice · Medium

Check yourself

4 questions · not saved while you're signed out

Use these questions to check your understanding and compare explanations. Your score does not affect track completion.

0 / 4 correct

For a 32 by 32 input and a 3 by 3 kernel with dilation 1, what are the output spatial sizes for the two convolutions below?

Choose one answer to reveal the explanations. Answers are kept only while this page is open.

import torch
from torch import nn

x = torch.zeros(1, 1, 32, 32)
for stride, padding in [(1, 0), (2, 1)]:
    conv = nn.Conv2d(1, 1, 3, stride=stride, padding=padding)
    print(tuple(conv(x).shape[-2:]))
Question 1 of 4