How to resize the tensor from rectangle to square


I want to crop some patches from an image and resize them to the same size to serve as the input to my CNN.However, the patches are rectangle and have different size.

For example, I have two patches whose size are 70x40 and 50x80. I want to resize them to 64x64. Then I will feed them into my CNN and the size of output is 64x64. Finally,I will resize the refined patches(64x64) back to their original size(70x40 and 50x80).

Now I know nn.upsamle may be helpful to me. However, I am not very clear is there any problem(such as the image quality?) for the transform from rectangle to square and vice verse


nn.upsample is indeed useful for such an operation, and the operation will be lossy (yes image quality will suffer).