Resizing does not work

I have this code and I spent a lot of time figuring out why the size is still the same [28,28]:

class FashionDataset(Dataset):
    def __init__(self,dataset_dir,train_option,transform=None):
        self.dataset = datasets.FashionMNIST(root=dataset_dir,
                                           train=train_option,
                                           download=True)
        self.transform = transform
        self.labels = self.dataset.targets
        
    def __len__(self):
        return len(self.dataset)

    def __getitem__(self, index):
        data, target = self.dataset[index]
        data = self.transform(data)
        return index, data, target

transform = transforms.Compose([transforms.ToTensor(),transforms.Resize((224, 224))])

train_dataset = FashionDataset(dataset_dir = dataset_dir, train_option = True, transform = transform)

test_dataset = FashionDataset(dataset_dir = dataset_dir, train_option = False, transform = transform)

train_loader = DataLoader(train_dataset, 
                          batch_size=batch_size,
                          sampler=SubsetRandomSampler(range(len(train_dataset))))

test_loader = DataLoader(test_dataset, 
                         batch_size=batch_size, 
                         shuffle=False)

Thank you for your help in advance.

Your code works as expected:

idx, x, y = next(iter(train_loader))
print(x.shape)
# > torch.Size([10, 1, 224, 224])

idx, x, y = next(iter(test_loader))
print(x.shape)
# > torch.Size([10, 1, 224, 224])

Thank you @ptrblck , my mistake was I was trying to print the shape by printing train_loader.dataset.data.shape which is different when you iterate through the for loop or next() because it calls getitem which involves the transforms.