RandomCrop doesn't work

import torch
import torchvision
import torchvision.transforms as transforms

train_transforms = transforms.Compose([
	transforms.RandomCrop(
		size=(32, 32), 
		padding=4,
    padding_mode='edge'),
	transforms.ToTensor()])

results in error

TypeError                                 Traceback (most recent call last)
<ipython-input-20-8e4749e99a47> in <module>()
      7                 size=(32, 32),
      8                 padding=4,
----> 9     padding_mode='edge'),
     10 	transforms.ToTensor()])

TypeError: __init__() got an unexpected keyword argument 'padding_mode'

According to https://pytorch.org/docs/stable/torchvision/transforms.html#torchvision.transforms.RandomCrop there is indeed an argument named padding_mode.
What am I doing wrong?

Could you check your torchvision version and update if necessary?
I guess you are working with an older version, where this argument is not available.

I am using Google Colab. My torch version is 1.0.0 and torchvision version is 0.2.1

As far as I can see, padding_mode was added in May 2018.
Could you try to reinstall torchvision in your Colab environment?

I don’t know if that’s help but I have the same problem of torch 0.4.0and torchvision 0.2.1. I look into the transforms.py file in my Anaconda files, and the function RandomCrop is not the same than the one at Documentation. There is no argument fill and padding_mode. However 0.2.1 seems to be the latest version.

I’m not sure how the versions for torchvision are bumped, but I would just try to reinstall the package and check if the source matches the current documentation.