Hi Ishal!



 Ishal_Garg:

But what do you mean by " each batch you
generate will be  on average  equally weighted between the two
classes"


Using WeightedRandomSampler with a dataloader will build
batches by randomly sampling from your training set.
Let’s say you have six samples in your dataset, with items 1, 2,
and 3 being from class 0, and items 4, 5, and 6 being from class
1.
Let’s build a batch of four items by rolling a six-sided die four
times.
For one batch you roll 3, 6, 4, 6.  This batch will have one class-0
sample, and three class-1 samples – not fifty-fifty.  Then you roll
5, 2, 4, 3.  This batch will be fifty-fifty.
It’s random whether any specific batch is fifty-fifty, but on average
your batches will consist of 50% class-0 samples and 50% class-1
samples.
Best.
K. Frank