Solved by ptrblck in post #2 
              
              
                You could use an adaptive pooling layer first and then calculate the average using a view on the result: 
x = torch.randn(16, 14, 14)
out = F.adaptive_max_pool2d(x.unsqueeze(0), output_size=1)

# Calculate result manually to compare results
out_manual = torch.stack([out[:, i:i+4].mean() for i in ran…