torchvision.transforms.Resize not existing?

There is clearly a torchvision.transforms.Resize documented here:

but when I use it

transforms.Resize(size=(224, 224)),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])

I get the following error:

AttributeError: ‘module’ object has no attribute ‘Resize’

As soon as I change transforms.Resize(size=(224, 224)), to something else like transforms.CenterCrop(224), it starts working.

What is the reason for this problem and how can it be solved?


Are you sure your version of torchvision is up to date?
If you have an old version of torchvision transforms.Scale might work.

yes, the problem was resolved after upgrading torchvision.

The link to the docs that you provided is for the current version of the source code.
If you replace “master” with “0.3.0” you get the docs for pytorch version 0.3.0 (which is currently the latest release) …

… which doesn’t make that much sense when you consider that the latest release of torchvision is version 0.2.0.

yes, I should mention that I actually upgraded both pytorch and torchvision to the latest version, and the problem was fixed.

1 Like

I’m facing the same issue with PyTorch version 1.0.1 (the latest stable release). I have installed torchvision via pip.
When I try to check the version of torchvision, I do not see the version class attribute. How do I make sure that mhy torchvision is up-to-date?

I am facing the same problem. How can I upgrade the torchvision?

Thanks in advance for your cooperation.

You can use this command

pip install torchvision==0.5.0+cpu -f