Question re: F.max_pool2d parameters

I’m going through the Pytorch Recipe: Defining a Neural Network in Pytorch, and I have a question regarding the parameters for F.max_pool2d.

In the above code, there are two parameters for F.max_pool2d: x and 2.

My questions:

  1. To clarify, is the first parameter ‘x’ just representing our data?
  2. I think I read somewhere that the second parameter is the kernel size, but I’m confused because I thought pooling doesn’t use kernels (aka filters)? I thought only the convolution operation uses kernels/filters? What is this kernel doing in the pooling operation? Or does this second parameter represent something else?

Any help would be appreciated, thank you!

  1. Yes, x is the input activation.
  2. Pooling layers do use a kernel (which doesn’t contain trainable weights) and you can imagine it as a “window” or “patch” which is selecting the input locations for the pooling operation. E.g. a kernel size of 2 would select a 2x2 window (= 4 pixels) and in case of nn.MaxPool2d it would then return the max. value of these 4 inputs in the output activation.