Subset object has no attribute data

Hi everyone, I’m new to pytorch.
I’m trying to split the original MNIST test set into a validation and a test set of the same size.
When i try

dataset_train = torchvision.datasets.MNIST("./mnist", train=True, download=True)
valid_and_test_set = torchvision.datasets.MNIST("./mnist", train=False, download=True)
dataset_valid, dataset_test =,[5000, 5000])

mu =
mu_valid =

On the last line I get the error

AttributeError: 'Subset' object has no attribute 'data'

How can I handle this?
Thank you in advance. should do.

1 Like