Solved by ptrblck in post #2 
              
              
                Did you initialize both models with the same values? 
Note that torch.Tensor creates a tensor with uninitialized memory, so that you might get arbitrary values (including Infs and NaNs). 
I would recommend to initialize your custom model with some initialization method from torch.nn.init to make sur…