Solved by KFrank in post #2 
              
              
                Hi Tejan! 

You have this backwards – you want to weight the less-frequent 
classes more heavily in your loss function.  The most common 
weighting scheme would be the reciprocal of what you have, 
100.0 / torch.tensor ([20.0 ,30.0 ,40.0 ,10.0]) 

My preference is to calculate the weights using the …