Warm tip: This article is reproduced from serverfault.com, please click

How to perform sum pooling in PyTorch

发布于 2018-06-13 13:46:51

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 ?

Questioner
adeelz92
Viewed
0
benjaminplanche 2018-06-13 22:20:43

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.