Solved by KFrank in post #2 
              
              
                Hi Андрей! 

You have two mistakes in your calculation:  First, NLLLoss does not 
take the log() of its input, but you do in your manual calculation. 
Second, when you manually calculate the weighted average, you 
should be dividing by 3 * 2 (not (3 * 4)).  Thus: 
>>> import math
>>> import torch
>>>…