Question 10
You are given:
• Image size: 64 × 64 • Patch size: 16 × 16 • Number of input channels: 3 (RGB) • Embedding dimension: 128
You want to implements patch embedding using a single nn.Conv2d layer in PyTorch such that:
• Each patch becomes one token. • The convolution extracts non-overlapping patches. • The output shape becomes:
(B, 128, 4, 4)
where B is batch size.
You write:
Which of the following configurations correctly implement non-overlapping 16×16 patches?
kernel_size = 3, stride = 1, padding = 1
kernel_size = 16, stride = 8, padding = 0
kernel_size = 16, stride = 16, padding = 0
kernel_size = 4, stride = 4, padding = 0