I have an input x by dimension 128x512x1x1 and I need to reduce it to 10x10x1x1, how can I do that using Conv 1x1 in Pytorch?
any help would be appreciated.
I’m assuming the given dimensions are in y, x, c, n or y, x, n, c (which seems to be an unusual ordering) as otherwise it would imply a reduction in the batch dimension which seems unintended.
A simple method would be to simply increase the stride:
>>> import torch >>> a = torch.randn(1, 1, 128, 512) >>> c = torch.nn.Conv2d(1, 1, 1, (13, 52)) >>> o = c(a) >>> o.shape torch.Size([1, 1, 10, 10])
However, you may wish to downsample in a “smoother” way, so you might want to take a look at e.g., AdaptiveAvgPool2D:
thank you very much.