Solved by ptrblck in post #2 
              
              
                The weighting should balance the losses and might thus also balance the accuracy. I.e. while the class2 accuracy might increase the other two might decrease. 


Your current target might not use the class2 index. This code shows the difference: 


class_weights = torch.tensor([1., 1., 2.])
ces1 = …