Solved by ptrblck in post #2 
              
              
                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.