Weighted Random Samplers in pytorch
I am new to samplers and don't understand why we should use a weighted random sampler. Can anyone explain it to me? Also, should we use a weighted random sampler for the validation set?

This is very much a PyTorch-independent question and, as such might appear a bit off-topic.
Take a classification task, your dataset may contain more instances of a certain class making this class overrepresented. This can usually lead to some issues. Indeed, during training, your model will be presented with more instances from one class than the others. In that sense, it can become biased towards that prominent class.
To counter that you can use a weighted sampler that will effectively level the unequal number of instances such that, on average, during one epoch, the model will have seen as many examples belonging to each of your classes. This will allow having balanced learning with respect to your class, independently from the fact that you may have different numbers of instances per class.
To answer your second question, I don't think you should be using a weighted sampler on your validation. There is no need to adopt a specific sampling policy. The point of validation is to see the performance of your fixed model on unseen data. Similar to the test set, where you won't have access to the class statistics to actually use a weighted sampler.
