Dealing with imbalanced datasets in pytorch

You can also apply class weighting using the weight argument for a lot of loss functions.
nn.NLLLoss or nn.CrossEntropyLoss both include this argument.
You can find all loss functions here.

9 Likes