Solved by ptrblck in post #2 
              
              
                The code looks generally alright, but I would not use torch.Tensor to create the initial parameter, as it will use uninitialized memory and will contain whatever was stored in the memory you are using. 
This would also mean that it might contain NaN values etc. 
Use the factory methods, such as torc…