Subsample class ballencing


Sorry if a similar topic already exists. I am trying sample the data in each batch during training so that each class represented in the batch has at least n numbers of each class when possible. So say I have 1000 classes if the batch size is 16 and I want n to be 4 I want the batch to only contain 4 different classes in each batch