Kernel size is the spatial extent of a convolutional or pooling window. In PyTorch, it is the numeric argument that determines how many neighboring pixels each operation considers. section 3.4.2 section 3.5
Use kernel size to control the local operation and its interaction with stride and padding:
- Convolutions commonly use stride 1, evaluating every possible location; padding can preserve height and width. section 3.4.2 section 3.5
- Max pooling uses the kernel as its selection window and commonly sets stride equal to kernel size, shrinking each dimension by that factor. section 3.5
- GAN architectures may choose kernel size 5 for ordinary convolutions and 4 for transposed convolutions to produce smoother, evenly contributed expansions. section 9.4.1
PyTorch choices
A same-sized convolution can use nn.Conv2d(..., 3, padding=3//2). A GAN helper instead passes k_size=5 to nn.Conv2d and uses k_size_t=4 with nn.ConvTranspose2d(..., stride=2, padding=1). section 3.4.2 section 9.4.1
Figure 3.14 Example of max pooling for K = 2 (top) and K = 3 (bottom). Each region of the input (left) has a color indicating the group of pixels participating in the pooling, and the output (right) shows which value was selected from the input region. Note that the output is smaller than the input by a factor of K.
Compare K=2 and K=3 max-pooling windows and see how kernel size reduces the output. section 3.5



