Mini Batches respecting class proportion/frequency

Hi All,

I would like to know if there is an efficient way to create mini-batches which respect class proportion ( that is, if my training is formed by 95% samples in class 1 and 5% class2, I would like to have mini-batches respecting these frequencies).

Thank you!

I have currently found the answer here: