Skip to content

How to do gradient clipping? Is there any deepXDE function for that? #1920

Answered by vl-dud
LeeStr1 asked this question in Q&A
Discussion options

You must be logged in to vote

Is there a built-in function or method in DeepXDE for enabling gradient clipping?

I think not.

If not, is there a recommended way to implement it manually, perhaps by modifying the optimizer or through a callback?

You can use clip_grad_norm_ (PyTorch): https://pytorch.org/docs/stable/generated/torch.nn.utils.clip_grad_norm_.html
Apply it inside train_step:

def train_step(inputs, targets, auxiliary_vars):

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lululxvi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants