How to resize feature maps?

I want to rescale (i.e. resize) the output of a convolution layer. I don’t mean to reshape the tensor, but actually make an n by n map and change it to an m by m for the entire minibatch. Is this possible in PyTorch?


You could have a look at the Upsample module.

1 Like

That is helpful, but my goal is to downsample to an arbitrary size. Let’s say I have 12 x 64 x 64 feature map and want to change it to a 12 x 50 x 50. Using downsampling/padding doesn’t always work.

What operation do you want to use, how do you want to map values from one domain into the other?

I am also not sure why the following isn’t what you were looking for.

torch.nn.Upsample(size=(50, 50), mode='bilinear')(torch.rand(1, 3, 64, 64))


Oh, I can use Upsample to downsample! I guess the name confused me. Thank you Simon; this is exactly what I am looking for! I am loving PyTroch.