When I use this line of codes, everything works fine.
train_transform = T.Compose([
T.RandomResizedCrop(224),
T.ToTensor(),
])
train_dset = ImageFolder(train_dir, transform=train_transform)
train_loader = DataLoader(train_dset,
batch_size = batch_size,
shuffle=True)
data_iter = iter(train_loader)
images, labels = next(data_iter)
print("Size of x ", images.size())
it outputs:
Size of x torch.Size([32, 3, 224, 224])
But if I will change RandomResizedCrop(224)
to Resize(224)
it ouputs:
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 335 and 334 in dimension 3 at c:\a\w\1\s\tmp_conda_3.6_061433\conda\conda-bld\pytorch_1544163532679\work\aten\src\th\generic/THTensorMoreMath.cpp:1333
Could you help me?
UPDATE:
I just found that my code works ok with Tiny Imagenet Dataset, but fails with COCO Animals dataset (8 classes)