on-internet
← Community

How to use autograd.grad() to implement gradient clipping in Pytorch?

Stack Overflow ·

Looking for a way to implement gradient clipping for gradients computed using autograd.grad instead of .backward. Also to better understand how clipping is done in Pytorch. It seems from reading that the various clipping functions require .backward for backpropagation. I couldn't find an example without it. The autograd.grad method would be used to calculate dL/dw for the respective weights. The computed gradients would be updated manually. The built-in optimizer function in torch wouldn't be used.

Comments

Sign in or sign up to comment and upvote.

No comments yet.