Error about torch.FloatTensor attribute 'resize'

Hi everyone,
I have met a problem when loading my own dataset,

trainset = torchvision.datasets.ImageFolder(root='../dataset/', 

trainloader =, batch_size=batch_size,
                                      shuffle=True, num_workers=2)

data = iter(trainloader)
imgs =[0]

And I got the error:

AttributeError: Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/torch/utils/data/”, line 41, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File “/usr/local/lib/python2.7/dist-packages/torchvision/datasets/”, line 118, in getitem
img = self.transform(img)
File “/usr/local/lib/python2.7/dist-packages/torchvision/”, line 34, in call
img = t(img)
File “/usr/local/lib/python2.7/dist-packages/torchvision/”, line 199, in call
return img.resize(self.size, self.interpolation)
AttributeError: ‘torch.FloatTensor’ object has no attribute ‘resize’

any idea? thanks.


there are two types of transforms: Those that take PIL images as input and those that take Tensors. Scale takes an image (which has a resize method).
Note that in order to be able to pass a tuple to the Scale transform, you need to install from the master branch.

Best regards


Thanks Thomas. Actually, I just noticed it.