Coverting a Pytorch tensor of shape [1,3,19,19] to [1,3,9,9]

I am using a single image GAN model(ConSINGan) for image generation. The dimension of the input image is [1,3,9,9]. However, the size of the image tensor used for interpolation is [1,3,19,19], which I want to change to [1,3,9,9]. How do I reshape torch tensors so that only the last 2 indices of the tensor are reshaped or downsampled.

I tried changing it into numpy first and then doing it, but is there any other way to do it directly without changing it to numpy?

Thank you in advance. !!!

Hi,

You can use torch.nn.functional.interpolate to the down/up scaling for any tensors:

Bests

1 Like

Thank you so much BOSS ! This worked ! :pray: