It seems like you are looking for interpolate (a function in nn.functional):

import torch.nn.functional as nnf

x = torch.rand(5, 1, 44, 44)
out = nnf.interpolate(x, size=(224, 224), mode='bicubic', align_corners=False)

If you really care about the accuracy of the interpolation, you should have a look at ResizeRight: a pytorch/numpy package that accurately deals with all sorts of "edge cases" when resizing images. This can have an effect when directly merging features of different scales: inaccurate interpolation may result in misalignments.

Answer from Shai on Stack Overflow
Discussions

Resize tensor without converting to PIL image?
I have 6-channel images (512x512x6) that I would like to resize while preserving the 6-channels (say to 128x128x6). torchvision.transforms.Resize expects a PIL image in input but I cannot (& do not want to) convert my images to PIL. Any idea how to do this within torchvision transforms (i.e. ... More on discuss.pytorch.org
🌐 discuss.pytorch.org
17
3
August 2, 2019
python - Resize PyTorch Tensor - Stack Overflow
Are you sure you want to use resize the tensor, not reshape? And if you want to resize it, is there anything you can archive with resize, what isn't possible by using slicing operations? ... I think you have a point. Actually, now that you mention it I'm realizing that I probably should have used reshape in the first place. Here's the output of t.size() before and after the operation: torch... More on stackoverflow.com
🌐 stackoverflow.com
Resize stack of tensors
Pytorch uses the Grammer of [N, C, H, W] so before you converting the image to tensor you need to change the default image [H,W,C] => [C,H,W] More on reddit.com
🌐 r/pytorch
4
1
May 22, 2023
How to resize a tensor or image
In pytorch, I have a tensor data with size (B,C,T1,V,), how could a resize it to (B,C,T2,V,) like image_resize does(eg:tf.image.resize_bilinear intensoflow)?where T2 may be either larger or smaller than T1; I find import… More on discuss.pytorch.org
🌐 discuss.pytorch.org
6
0
April 27, 2018
🌐
Medium
medium.com › @amit25173 › expert-guide-to-resizing-pytorch-tensors-b88d3f34a76b
Expert Guide to Resizing PyTorch Tensors | by Amit Yadav | Medium
February 9, 2025 - By cloning a tensor, you ensure that modifications to the resized version don’t affect the original, which is particularly valuable for tasks involving gradient calculations or reuse of initial data. Purpose and Use Cases: Use torch.clone when you want to create an independent copy before resizing or reshaping.
🌐
PyTorch Forums
discuss.pytorch.org › t › resize-tensor-without-converting-to-pil-image › 52401
Resize tensor without converting to PIL image? - PyTorch Forums
August 2, 2019 - I have 6-channel images (512x512x6) that I would like to resize while preserving the 6-channels (say to 128x128x6). torchvision.transforms.Resize expects a PIL image in input but I cannot (& do not want to) convert my im…
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-resize-a-tensor-in-pytorch
How to resize a tensor in PyTorch? - GeeksforGeeks
July 23, 2025 - We can resize the tensors in PyTorch by using the view() method. view() method allows us to change the dimension of the tensor but always make sure the total number of elements in a tensor must match before and after resizing tensors.
🌐
TutorialsPoint
tutorialspoint.com › how-to-resize-a-tensor-in-pytorch
How to resize a tensor in PyTorch?
November 6, 2021 - Original tensor: tensor([1., 2., 3., 4., 5., 6.]) Tensor after resize: tensor([[1., 2., 3.], [4., 5., 6.]]) You can use -1 as a placeholder for one dimension, and PyTorch will automatically calculate it based on the total number of elements − · import torch T = torch.Tensor([1, 2, 3, 4, 5, 6]) # Let PyTorch calculate the first dimension (-1, 3) x1 = T.view(-1, 3) print("Using view(-1, 3):") print(x1) # Let PyTorch calculate the second dimension (2, -1) x2 = T.view(2, -1) print("Using view(2, -1):") print(x2)
🌐
Reddit
reddit.com › r/pytorch › resize stack of tensors
r/pytorch on Reddit: Resize stack of tensors
May 22, 2023 -

I have a tensor with shape torch.Size([5, 240, 240, 155]) which is a 5 different channels with 155 images of 240x240. I want to make those images 128x128 so the final shape would look like this.

torch.Size([5, 128, 128, 155]).

transforms.Resize only affects the last two dimensions, and reshaping in messes up the images, as it does not understand that there are 155 different images and mixes them up. Is there a better way to do this than a for loop that iterates over every image, reshapes it and then concatenate them?

Find elsewhere
🌐
PyTorch
docs.pytorch.org › vision › main › generated › torchvision.transforms.Resize.html
Resize — Torchvision main documentation
Resize the input image to the given size. If the image is torch Tensor, it is expected to have […, H, W] shape, where …
🌐
PyTorch
docs.pytorch.org › reference api › torch.tensor › torch.tensor.resize_as_
torch.Tensor.resize_as_ — PyTorch main documentation
January 1, 2023 - Tensor.resize_as_(tensor, memory_format=torch.contiguous_format) → Tensor# Resizes the self tensor to be the same size as the specified tensor. This is equivalent to self.resize_(tensor.size()). Parameters: memory_format (torch.memory_format, ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › reshaping-a-tensor-in-pytorch
Reshaping a Tensor in Pytorch - GeeksforGeeks
September 1, 2021 - Syntax: tensor.resize_(no_of_tensors,no_of_rows,no_of_columns) ... Example 1: Python code to create an empty one D tensor and create 4 new tensors with 4 rows and 5 columns ... # importing torch module import torch # create one dimensional tensor a = torch.Tensor() # resize the tensor to 4 tensors.
🌐
TutorialsPoint
tutorialspoint.com › pytorch-how-to-resize-an-image-to-a-given-size
PyTorch – How to resize an image to a given size?
January 6, 2022 - The Resize() transform resizes the input image to a given size. It's one of the transforms provided by the torchvision.transforms module. Resize() accepts both PIL and tensor images.
🌐
PyTorch Forums
discuss.pytorch.org › t › how-to-resize-a-tensor-or-image › 17091
How to resize a tensor or image - PyTorch Forums
April 27, 2018 - In pytorch, I have a tensor data with size (B,C,T1,V,), how could a resize it to (B,C,T2,V,) like image_resize does(eg:tf.image.resize_bilinear intensoflow)?where T2 may be either larger or smaller than T1; I find import…
🌐
GitHub
github.com › pytorch › vision › issues › 2950
In transforms.Resize, tensor interpolate is not the same as PIL resize. · Issue #2950 · pytorch/vision
November 3, 2020 - Resize supports tensors by F.interpolate, but the behavior is not the same as Pillow resize. ... import urllib from PIL import Image from torchvision import transforms from matplotlib import pyplot as plt size = 112 img = Image.open(urllib....
Author: pytorch
🌐
Jake Tae
jaketae.github.io › study › pytorch-tensor
PyTorch Tensor Basics - Jake Tae
October 10, 2020 - .view() is another common function that is used to resize tensors. It has been part of the PyTorch API for quite a long time before .reshape() was introduced. Without getting into too much technical detail, we can roughly understand view as being similar to .reshape() in that it is not an in-place ...
🌐
Reddit
reddit.com › r/pytorch › resize 3d tensor
r/pytorch on Reddit: Resize 3d tensor
July 22, 2023 -

I want to resize my [512,512,96] tensor to [64,64,64]. Torchvision.transoforms.Resize only works with the last two dimensions

image = T.Resize(64)(image) turns torch.Size([512, 512, 96]) to torch.Size([512, 341, 64]) ???(no idea where the 341)

image = T.Resize((64,64))(image) turns torch.Size([512, 512, 96]) to torch.Size([512, 64, 64]) .

image = T.Resize((64,64,64))(image) throws this error

If size is a sequence, it should have 1 or 2 values

Any ideas, besides iterating over all the images in a for loop and concatenating them

🌐
GitHub
github.com › assafshocher › ResizeRight
GitHub - assafshocher/ResizeRight: The correct way to resize images or tensors. For Numpy or Pytorch (differentiable). · GitHub
This is a resizing packge for images or tensors, that supports both Numpy and PyTorch (fully differentiable) seamlessly. The main motivation for creating this is to address some crucial incorrectness issues (see item 3 in the list below) that exist in all other resizing packages I am aware of.
Author: assafshocher
🌐
Readthedocs
torcheeg.readthedocs.io › en › v1.0.10 › _modules › torcheeg › transforms › torch › resize.html
torcheeg.transforms.torch.resize — torcheeg 1.0.10 documentation
''' return super().__call__(*args, eeg=eeg, baseline=baseline, **kwargs) def apply(self, eeg: torch.Tensor, **kwargs) -> torch.Tensor: assert eeg.dim() == 3, f'The Resize only allows to input a 3-d tensor, but the input has dimension {eeg.dim()}' eeg = eeg.unsqueeze(0) align_corners = False ...