How to perform sum pooling in PyTorch. Specifically, if we have input (N, C, W_in, H_in)
and want output (N, C, W_out, H_out)
using a particular kernel_size
and stride
just like nn.Maxpool2d
?
You could use torch.nn.AvgPool1d
(or torch.nn.AvgPool2d
, torch.nn.AvgPool3d
) which are performing mean pooling - proportional to sum pooling. If you really want the summed values, you could multiply the averaged output by the pooling surface.