How to achieve a mixed behavior between maxpool and adaptive maxpool?

Suppose for a feature map of HxW, I would like to have a special kind of pooling that, after pooling, the output feature map is of size 1 x (W/2)?

Basically, it is adaptive maxpool along H dimension, but normal maxpool along W dimension.

Thanks in advance!

Seems that this cannot be done by current modules/functions, but after reading the code, I find that it is easy to implement, e.g in F. adaptive_max_pool2d, calculate true output_size based on input.size()

1 Like