Solved by KFrank in post #2 
              
              
                Hello Awesome! 

Passing weights to NLLLoss (and CrossEntropyLoss) gives, with 
reduction = 'mean', a weighted average where the sum of weighted 
values is then divided by the sum of the weights. 
In your `reduction = ‘none’ version: 
F.nll_loss(mi, target, weight=w, reduction=‘none’).mean()

by the…