Solved by albanD in post #6 
              
              
                Hi, 
You should use with torch.no_grad(): around the code that should not track gradients. That will solve the issue for clamp_