Should mini-batches contain an even mix of classes or can this be random?

I'm creating mini-batches to put into a CNN. Is it best to try and get an even mix of classes into each mini-batch (Scenario 1), or can this/should this be a random assortment of my classes (Scenario 2)?

Scenario 1:

  • I have 2 classes and a mini-batch size of 32. I should try and have 16 samples from each class in each mini-batch.

Scenario 2:

  • Same as 1, but I have a random distribution of samples in each mini-batch. So this could be 20 of one class and 12 of the other. Or even 32 of one class and none of the other on occasion.

Topic mini-batch-gradient-descent deep-learning neural-network

Category Data Science


Theoretically, it should not matter. As long as there are a large number of mini-batches and a good balance of classes within the training data.


If you use minibatch gradient descent , we should do random sampling. I think using just one class may lead to bias

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.