Unit 2 of 7 · about 4 hours · derive
Pooling, transposed convolution, receptive fields and cost
Resolution sets both what a unit can see and what training costs. A receptive field smaller than the object and an activation bill larger than memory fail the same run.
You'll be able to
- Derive receptive-field growth across stride, kernel and dilation choices.
- Count parameters, multiply-adds and activation bytes for a stated conv stack.
- Explain transposed convolution as learned upsampling and state when it is not an inverse.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Pooling from scratchD2L - convolutional and recurrent architecture route
Section 7.5: Maximum and Average Pooling (
pool2dfrom scratch), Padding and Stride, and Multiple Channels - Transposed convolutionD2L - convolutional and recurrent architecture route
Sections 14.10.1 and 14.10.2: Basic Operation and Padding, Strides, and Multiple Channels, including Connection to Matrix Transposition
- Receptive fields, downsampling and upsamplingUnderstanding Deep Learning - convolution and residual networks
Chapter 10, Sections 10.2.6 and 10.4 (pp. 167 to 174): receptive fields with Figure 10.6, and downsampling plus upsampling with Figures 10.11 to 10.13
Skip Section 10.5 Applications. Detection and segmentation are later topics.
Focus on
- Receptive field grows by times the product of earlier strides per layer. Stride-2 downsampling doubles the growth rate while quartering activations.
- One conv layer holds times times times weights plus biases, and costs about twice that many FLOPs per output position for the multiply-add.
- Pooling has no parameters, acts per channel, and stride-2 pooling quarters resolution. Max-pooling gives limited shift tolerance inside a window, not invariance.
- A transposed convolution applies the transpose of a downsampling weight matrix. It learns an upsampling and is not an inverse of any forward convolution.
Common mistakes · 3
- Quoting parameter counts as cost. FLOPs and activations scale with resolution, so doubling both sides quadruples both.
- Calling transposed convolution an inverse by name. It shares only the naming pattern, so its outputs need their own checks.
- Treating the receptive-field formula as uniform coverage. Center pixels feed more paths than edge pixels, so the formula gives the maximum extent.
Try it yourself
Closed-book, before checking anything
Conv2d(64, 128, kernel_size=3, stride=1, padding=1): output , 73,856 parameters, about 4.6e8 FLOPs, and about 1.6 MB of float32 output activations. Then grow the receptive field through two more layers to 7.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Three layers on a 1D input. What is the receptive-field size?Answer
7: . Each layer adds 2 to the extent at stride 1.
2.Stride-2 pooling quarters the positions. Why does it not quarter the compute of the next stage?Answer
Networks usually double the channels after downsampling. Convolution cost scales with positions times times , so doubling both channel counts restores the FLOPs exactly, while activation memory only halves.
3.Does a transposed convolution invert the convolution with the same weights?Answer
No. It applies the transposed weight matrix with its own learned weights, so equal shape back does not mean equal values.
4. stride-2 max-pooling. Which input shifts leave the output unchanged?Answer
A shift by 2 pixels shifts the output by one cell (equivariance on the coarse grid). A one-pixel shift leaves an output unchanged only when that window's maximum stays inside the window, which depends on the data; test with a shifted copy.
Practice
- UDL Chapter 10 Problems 10.8, 10.9, 10.11 and 10.14: channel counts and receptive fields
Problems (pp. 184 to 185): 10.8 (two-layer channel counts), 10.9 (three layers), 10.11 (receptive field with a stride-2 layer) and 10.14 ( kernel, 3 to 10 channels)
Solve on paper against the weight-shape formula before checking the section text.
- TrenTorch: FLOPs Estimation (Linear/Conv)
Implement
linear_flopsandconv2d_flopswith 2 FLOPs per multiply-add and one per bias addCheck it on the reproduce layer:
Conv2d(64, 128, kernel_size=3, padding=1)on gives 462,422,016 FLOPs before bias plus 401,408 for the bias, about 4.6e8.
You're done when
Your hand counts match the weight-shape formula on a new layer, and a shifted-input probe shows exactly which pooling outputs move.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 5 more in the section
- D2L - convolutional and recurrent architecture routeD2L authors · primary
Use why convolution, convolution layer, padding and strides, pooling, channels, batch normalization and ResNet, then RNN, BPTT, scratch RNN, GRU, LSTM, encoder-decoder and seq2seq. Work through the scratch mechanisms before concise APIs.
- Understanding Deep Learning - convolution and residual networksSimon J. D. Prince · required
Use Chapters 10 and 11 to sharpen convolutional invariance, receptive-field reasoning, residual paths and normalization. D2L remains the recurrent implementation route.
Also in this section
- Stanford CS231n - Assignments 1 and 2Stanford University · support
Use only the neural network, normalization, dropout, convolution and PyTorch components that match this section. Do not complete the course or unrelated vision tasks.
- Deep-ML candidate - convolution and recurrence problemsDeep-ML · optional
After the platform admission check, use at most one of 41 Conv2D, 62 RNN with BPTT, 287 GRU or 59 LSTM as a changed-prompt drill.
- TrenTorch - convolution cost and recurrent cellsTrenTorch · support
Solve FLOPs Estimation, GRU Forward and LSTM Forward after the D2L scratch models. Each reference cell matches torch.nn.GRUCell or LSTMCell.
- PyTorch nn.Conv2d referencePyTorch · reference
Read Signature and Shape for the exact floor formula with dilation, the groups divisibility rule with grouped and depthwise examples, and the weight layout . D2L and UDL teach the mechanism; this page is the shape contract to code against.
- PyTorch sequence packing utilitiesPyTorch · reference
Read
pack_padded_sequenceforlengths,enforce_sortedand batch-first at recognition depth: what packing skips and what contract it demands. Do not reimplement the packed format; pair it with the masked-loss implementation in D2L seq2seq.