Solved by tom in post #3 
              
              
                The obvious difference is that you pass a shape into t.new_ones but not into torch.ones_like. 
If I remember correctly, the torch.ones_like is an equivalent of the numpy API and t.new_ones is a “torch-legacy-idiomatic” replacement of a long-deprecated t.new method (which incidentally still seems to …