How to achieve a meanpooling method?

Hi,in a neural network,there is a input x and its size is torch.Size([16, 6, 150]),how can I let the x’size is [16, 1 ,150] by using meanpooling method?

You could try torch.mean(x, dim=1, keepdim=True).

1 Like