Global max pooling?

Hi, I am looking for the global max pooling layer.

Because in my case, the input shape is uncertain and I want to use global max pooling to make their shape consistent. But I do not find this feature in pytorch?

1 Like

You can use the functional interface of max pooling for that. In you forward function:

import torch.nn.functional as F
output = F.max_pool2d(input, kernel_size=input.size()[2:])

You can do something simpler like

import torch
output, _  = torch.max(input, 1)

(Be careful with the second argument. For 2d pooling it should be something like (1, 2) )