Solved by ptrblck in post #2 
              
              
                You could get the indices for all class1 labels and then index the labels and data: 
dataset = datasets.MNIST(root='./data')
idx = dataset.train_labels==1
dataset.train_labels = dataset.train_labels[idx]
dataset.train_data = dataset.train_data[idx]

However, your model won’t learn anything as you ju…