Solved by albanD in post #2 
              
              
                Hi, 
The torch.no_grad() hides these ops from the autograd engine so that when you call .backward(), they won’t be taken into account. So this is the right use here. 
The error you’re seeing is different: when the forward pass needs some Tensor to be able to compute the backward pass, this Tensor is…