Hi everyone, I don’t know how to handle this.
I did
valid_and_test_set = torchvision.datasets.MNIST("./mnist", train=False, download=True)
dataset_valid, dataset_test = torch.utils.data.random_split(valid_and_test_set,[5000, 5000])


class Convert(object):
    def __call__(self, img):
        return torch.unsqueeze(torch.from_numpy(np.array(img)), 0).float()

class Flatten(object):
    def __call__(self, img):
        return img.view(28*28)

class OneHot(object):
    def __call__(self, label):
        #target = torch.zeros(10, dtype=torch.float)
        #target[label] = 1.0
        return label

transform = transforms.Compose(
    [Convert(),
     transforms.Normalize(mean=[mu], std=[std]),
     Flatten()])

dataset_valid.transform = transform
dataset_valid.target_transform = OneHot()

dataloader_valid = torch.utils.data.DataLoader(dataset_valid, batch_size=500, num_workers=num_workers, pin_memory=True)

But when i try
 for batch in dataloader_valid:

I get the erorr
TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found <class 'PIL.Image.Image'>

Thank you guys.