Solved by ptrblck in post #2 
              
              
                The difference is most likely caused by the limited floating point precision and a different order of operations. You could use torch.float64 as the data type in case you need to increase the precision, but note that this data type would cause a performance hit on GPUs. 
A simple example is given he…