Solved by albanD in post #2 
              
              
                Hi, 
Do you actually see an error? 
From your comments, you should not set requires_grad=True on the output if you don’t need to access its .grad field later. 
And you don’t need to wrap things in Variables 
So it should work just fine yes.