I’m also wondering why the output of  nn.MSELoss is different to torch.mean((output-labels)**2).
I tried both on my code and the results differ.
I tried all kinds of mse loss calculations:
1. torch.mean(torch.square(output - labels))
2. torch.mean((output - labels)**2)
3. ((output - labels)**2).mean()
4. criterion = nn.MSELoss()
   loss = criterion(output, labels)
5. labels.requires_grad = True
   criterion = nn.MSELoss()
   loss = criterion(output, labels)
6. loss = F.mse_loss(output, labels)

It seems like that 1,2,3 all give the same result as do 4,5,6 but the results between those two groups differ. Why is this the case? I wonder if it has to do with the precision used in C since MSELoss calls the C api, could this be the case?