I’ve been using the torch.nn.Upsample method for scaling up images to different sizes as follows:

import torch
import numpy as np
a = np.random.uniform(0,1,(10,10))
a = torch.tensor(a)
a = a.unsqueeze(0).unsqueeze(0)
upsampler = torch.nn.Upsample(size=20, mode=‘bilinear’)
a_sized_up = upsampler(a)
print(a_sized_up.shape)


Out[23]: torch.Size([1, 1, 20, 20])

But my question is: are there any reasons why one cannot use the same method to downscale images if they are bigger than the required input size to some model?
For example one could use:

upsampler_down = torch.nn.Upsample(size=5, mode=‘bilinear’)
a_sized_down = upsampler_down(a)
print(a_sized_down.shape)


Out[33]: torch.Size([1, 1, 5, 5])

Which seems to work fine and looks sensible but does this make sense from a mathematical standpoint or will this method be introducing problems somehow in the background?
Many thanks in advance for advice on this