Solved by albanD in post #2 
              
              
                Hi, 
I think the best practice is to just remove all Variables and .data from your code. 
Variables are not needed anymore and you can pass requires_grad=True when you create a tensor if needed. 
The .data should be replaced by either .detach() if the goal is to prevent gradient from flowing back. O…