Adaptive Average Pooling 2d with relative output size

Is it possible to use Adaptive Average Pooling 2d not with a fixed, absolute output shape, but instead make it halve the image dimensions instead?

I would like the feature extraction to be fully convolutional and work on any image shape.

Solution:
Use the adaptive average pooling in the forward pass, where you have the shape information of the input available and can set the output shape to half the input shape.

In the original torchvision resnet50 implementation the adaptive average pooling layer is created during class initialization and I didn’t think of the idea that it doesn’t have to be this way.