You could use a WeightedRandomSampler
as described here. Note that it’s a random sampling process and thus a perfectly balanced batch is not guaranteed.
You could use a WeightedRandomSampler
as described here. Note that it’s a random sampling process and thus a perfectly balanced batch is not guaranteed.