Solved by liyz15 in post #2 
              
              
                They are equal, it results from precision of float. Change dtype of prediction and target to torch.float64 will give you closer answer, but float is float, it’s never exactly the same.