Ok sorry! Now it works, but I suppose using the full
torchvision.datasets.MNIST('./datasets/', train=True, transform=torchvision.transforms.ToTensor())
in the RandomSampler would have worked too, I’m sorry that was really a stupid error.
Just to ask one more thing, if I write something like this
data = torch.randn(10, 1, 28, 28)
target = torch.arange(10)

dataset = torch.utils.data.TensorDataset(data, target)

dataset “the same thing” as the dataset you define in your example? Where with “the same thing” I mean “another instance of the same class” (I suppose). So I can treat them equivalently?