Hello,
Take a look at this post

  
    
    
    Uniform class batch training vs. Not uniform class batch training vision
  
  
    For the first approach, you could access the targets in the CIFAR10 dataset and store the data indices for each label class. 
Then inside a custom Dataset, you could load a sample for each class and return the complete batch in the __getitem__ method. 
Note that for this approach you would manually create the batch in Dataset.__getitem__, thus you would have to set batch_size=1 in your DataLoader. 
If I understand the second use case correctly, you are just randomly sampling the data, so setting…