How to know the filter size and stride in AdaptiveAvgPool2d

I know that AdaptiveAvgPool2d is able to give the outputs of any defined size, but I don’t know what is the size of filter and stride it indeed use during calculation.
For example: if the input size is (14, 14), and the output size is (3, 3). What is the corresponding filter parameter? Suppose padding is 0, it seems there are multiple solutions.

  • filter 10x10 with stride 2x2;
  • filter 8x8 with stride 3x3;
  • filter 6x6 with stride 4x4;

Which one is correct? What is the calculation principle?

1 Like

Based on this implementation, the input of 14x14 and output of 3x3 would create the first start and end index as:

# First iteration
istartH = floor((0*14)/3) = 0
iendH = ceil((1*14)/3) = 5

# Second iteration
istartH = floor((1*14)/3) = 4
iendH = ceil((2*14)/3) = 10

So it seems that the window size is not constant (if I don’t have a mistake in the calculations).

3 Likes

Thanks very much for your reply, that really surprises me!