Create subset of FMNIST data set with equal number of items in classes

I want to split FMNIST data set into different sub-datasets containing :slight_smile:

  1. Containing random 500 samples for each class (so in total 500*no of class).
  2. Containing random 100 samples for each class.
    and so on…
    Is there a direct way of doing this. I tried with subset but it is resulting in imbalanced dataset.

You could get the target tensor and create split indices using sklearn.model_selection.train_test_split, which accepts the stratify argument to create balanced splits. :wink:
Once you have the indices, you could use Subsets to create the datasets.