WeightedRandomSampler - Imbalanced classes Multiclass classification

WeightedRandomSampler is used to provide weights to each sample, which is used during the sampling process of selecting the data samples for each batch.
The higher the weight assigned to a particular index, the more likely this data sample will be used in a batch.
To created batches of balanced classes, you would therefore assign a higher weight to samples from the minority class, and a lower weight to samples from the majority class.

Yes, the reduction is independent from the sampling strategy.

1 Like