How to load dataset with a different number of classes?

Hi, I want to load the available datasets, e.g., MNIST and CIFAR, with a different number of classes.

For example, I want to only use MNIST data which has an even label, i.e., 2,4,6,8.

Do I have to use torchvision.datasets.ImageFolder for that purpose? or Is there any other method to control it ?

Thanks in advance.

you can use ImageFolder, or you can simply copy the Dataset files https://github.com/pytorch/vision/tree/master/torchvision/datasets , modify them for your own purpose and used the modified versions.

1 Like

Thanks!

Your comment is really helpful.

Best regards,
Kimin Lee