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
🌐
PyTorch
docs.pytorch.org › vision › main › generated › torchvision.transforms.functional.resize.html
resize — Torchvision main documentation
resize · Shortcuts · torchvision.transforms.functional.resize(img: Tensor, size: list[int], interpolation: InterpolationMode = InterpolationMode.BILINEAR, max_size: Optional[int] = None, antialias: Optional[bool] = True) → Tensor[source]¶ · Resize the input image to the given size.
🌐
PyTorch
docs.pytorch.org › vision › 0.13 › generated › torchvision.transforms.functional.resize.html
resize — Torchvision 0.13 documentation
torchvision.transforms.functional.resize(img: torch.Tensor, size: List[int], interpolation: torchvision.transforms.functional.InterpolationMode = <InterpolationMode.BILINEAR: 'bilinear'>, max_size: Optional[int] = None, antialias: Optional[bool] = None) → torch.Tensor[source]¶
🌐
PyTorch
docs.pytorch.org › vision › 0.15 › generated › torchvision.transforms.functional.resize.html
resize — Torchvision 0.15 documentation
torchvision.transforms.functional.resize(img: Tensor, size: List[int], interpolation: InterpolationMode = InterpolationMode.BILINEAR, max_size: Optional[int] = None, antialias: Optional[Union[str, bool]] = 'warn') → Tensor[source]¶
🌐
PyTorch
docs.pytorch.org › vision › 0.19 › generated › torchvision.transforms.functional.resize.html
resize — Torchvision 0.19 documentation
resize · Shortcuts · torchvision.transforms.functional.resize(img: Tensor, size: List[int], interpolation: InterpolationMode = InterpolationMode.BILINEAR, max_size: Optional[int] = None, antialias: Optional[bool] = True) → Tensor[source]¶ · Resize the input image to the given size.
🌐
PyTorch
docs.pytorch.org › vision › 0.17 › generated › torchvision.transforms.functional.resize.html
resize — Torchvision 0.17 documentation
resize · Shortcuts · torchvision.transforms.functional.resize(img: Tensor, size: List[int], interpolation: InterpolationMode = InterpolationMode.BILINEAR, max_size: Optional[int] = None, antialias: Optional[bool] = True) → Tensor[source]¶ · Resize the input image to the given size.
🌐
PyTorch
docs.pytorch.org › vision › 0.9 › transforms.html
torchvision.transforms — Torchvision master documentation
torchvision.transforms.functional.resize(img: torch.Tensor, size: List[int], interpolation: torchvision.transforms.functional.InterpolationMode = <InterpolationMode.BILINEAR: 'bilinear'>) → torch.Tensor[source]¶
🌐
PyTorch
docs.pytorch.org › vision › 0.8 › transforms.html
torchvision.transforms — Torchvision 0.8.1 documentation
torchvision.transforms.functional.resize(img: torch.Tensor, size: List[int], interpolation: int = 2) → torch.Tensor[source]¶
🌐
Medium
medium.com › @MarkAiCode › resize-images-with-pytorch-a-comprehensive-guide-b9025b8fe79d
Resize Images with PyTorch: A Comprehensive Guide | by Markaicode | Medium
August 5, 2024 - import torch import torchvision.transforms as transforms from PIL import Image · PyTorch offers a simple way to resize images using the transforms.Resize function.
Find elsewhere
🌐
PyTorch
docs.pytorch.org › vision › 0.11 › transforms.html
torchvision.transforms — Torchvision 0.11.0 documentation
torchvision.transforms.functional.resize(img: torch.Tensor, size: List[int], interpolation: torchvision.transforms.functional.InterpolationMode = <InterpolationMode.BILINEAR: 'bilinear'>, max_size: Optional[int] = None, antialias: Optional[bool] = None) → torch.Tensor[source]¶
🌐
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
docs.pytorch.org › vision › main › generated › torchvision.transforms.functional.resized_crop.html
resized_crop — Torchvision main documentation
torchvision.transforms.functional.resized_crop(img: Tensor, top: int, left: int, height: int, width: int, size: list[int], interpolation: InterpolationMode = InterpolationMode.BILINEAR, antialias: Optional[bool] = True) → Tensor[source]¶
🌐
GitHub
github.com › pytorch › vision › issues › 7518
Resize transform applied even if input size equal to desired output size · Issue #7518 · pytorch/vision
April 16, 2023 - The functional transform resize, will be applied even if the input image is at the same size like the desired output. import torch from torchvision.transforms import functional as F x = torch.Tensor(1,100,200) x_resized = F.resize(x, (100,200)) ...
Author: pytorch
🌐
DEV Community
dev.to › hyperkai › resize-in-pytorch-47j7
Resize in PyTorch - DEV Community
May 16, 2025 - from torchvision.datasets import OxfordIIITPet from torchvision.transforms.v2 import Resize from torchvision.transforms.functional import InterpolationMode r = Resize(size=100) r = Resize(size=100, interpolation=InterpolationMode.BILINEAR, max_size=None, antialias=True) r # Resize(size=[100], interpolation=InterpolationMode.BILINEAR, # antialias=True) r.size # [100] r.interpolation # <InterpolationMode.BILINEAR: 'bilinear'> print(r.max_size) # None r.antialias # True origin_data = OxfordIIITPet( root="data", transform=None ) s1000_data = OxfordIIITPet( # `s` is size.
🌐
GitHub
github.com › pytorch › pytorch › issues › 148840
[ONNX] Export fails on `torchvision.transforms.functional.resize` (_upsample_bilinear2d_aa) · Issue #148840 · pytorch/pytorch
March 9, 2025 - import torch import torchvision class Model(torch.nn.Module): def __init__(self): super().__init__() def forward(self, x): y = torchvision.transforms.functional.resize(x, size=[1024, 1024]) return y model = Model() x = torch.rand(1, 3, 400, 500) y = model(x) onnx_model = torch.onnx.export(model, x, dynamo=True) The error message I got is: /home/fabian/.local/lib/python3.12/site-packages/onnxscript/converter.py:823: FutureWarning: 'onnxscript.values.Op.param_schemas' is deprecated in version 0.1 and will be removed in the future.
Author: pytorch
🌐
RubyDoc
rubydoc.info › gems › torchvision › 0.2.1 › TorchVision › Transforms › Functional
RubyDoc.info: Class: TorchVision::Transforms::Functional – Documentation for torchvision (0.2.1) – RubyDoc.info
lib/torchvision/transforms/functional.rb · .center_crop(img, output_size) ⇒ Object · .crop(img, top, left, height, width) ⇒ Object · .hflip(img) ⇒ Object · .normalize(tensor, mean, std, inplace: false) ⇒ Object · .resize(img, size) ⇒ Object · .resized_crop(img, top, left, height, width, size) ⇒ Object ·
🌐
GitHub
github.com › pytorch › vision › issues › 2580
Why the supoort inputs of torchvision.transforms.functional.crop() and resize () on Windows is different from docs on website? · Issue #2580 · pytorch/vision
August 12, 2020 - The docs on the website: torchvision.transforms.functional.resize() and torchvision.transforms.functional.crop() are written that the two functions support both PIL and tensor as inputs.
Author: pytorch
🌐
PyTorch
docs.pytorch.org › vision › stable › transforms.html
Transforming images, videos, boxes and more — Torchvision 0.29 documentation
Transforms are available as classes like Resize, but also as functionals like resize() in the torchvision.transforms.v2.functional namespace.
🌐
PyTorch
docs.pytorch.org › vision › stable › generated › torchvision.transforms.Resize.html
torchvision.transforms. - Resize
Transforming images, videos, boxes and more > Resize · Shortcuts · class torchvision.transforms.Resize(size, interpolation=InterpolationMode.BILINEAR, max_size=None, antialias=True)[source]¶ · Resize the input image to the given size. If the image is torch Tensor, it is expected to have ...
🌐
Chsasank
chsasank.com › vision › transforms.html
Transforms — Torchvision master documentation
class torchvision.transforms.Resize(size, interpolation=2)[source]¶ · Resize the input PIL Image to the given size. class torchvision.transforms.Scale(*args, **kwargs)[source]¶ · Note: This transform is deprecated in favor of Resize. class torchvision.transforms.CenterCrop(size)[source]¶ ·