Skip to content

Commit

Permalink
Pytorch backend: clear gradients (lululxvi#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelldaneker authored Nov 15, 2022
1 parent 319e1c9 commit b184122
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deepxde/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def outputs(training, inputs):
else:
inputs = torch.as_tensor(inputs)
inputs.requires_grad_()
# Clear cached Jacobians and Hessians.
grad.clear()
return self.net(inputs)

def outputs_losses(training, inputs, targets, losses_fn):
Expand Down

0 comments on commit b184122

Please sign in to comment.