Specify size of per-class samples used for training

I’m trying to explore using different size of per-class samples for transfer learning. For example, I want to only take 10 images per class for training versus 50 images per class. How do I specify the number of per-class samples without reorganizing the dataset?

One thing you can do is what I did here. You can randomly select image paths of 10 images of a particular class. After you have a list which has paths of these image files, you can define the rule in __getitem__. Dataloader will open the image on the fly using the path (by iterating over the list) and converting it into a tensor. You can have a look in the repo for more details. The concept is same.