Learn Before
Example
LeNet-5 Layer-by-Layer Shape Trace
Passing a single-channel image through LeNet-5 produces the following shapes at each layer:
- Conv2d (, padding , channels): output
- Sigmoid: output
- AvgPool2d (, stride ): output
- Conv2d (, no padding, channels): output
- Sigmoid: output
- AvgPool2d (, stride ): output
- Flatten: output
- Linear () + Sigmoid: output
- Linear () + Sigmoid: output
- Linear (): output
The first convolutional layer uses pixels of padding to preserve the spatial dimensions of the input, compensating for the reduction that a kernel would otherwise cause. The second convolutional layer uses no padding, reducing height and width by pixels each. As the stack deepens, the number of channels increases () while spatial dimensions shrink, until flattening yields a -element vector.
0
1
Updated 2026-06-29
Tags
D2L
Dive into Deep Learning @ D2L