Skip to content

Commit

Permalink
Jacobian in forward-mode handles gradient explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
lululxvi committed Dec 16, 2023
1 parent b9adcb6 commit e505ac1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions deepxde/gradients/gradients_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ def __call__(self, i=0, j=None):
if j is not None and not 0 <= j < self.dim_x:
raise ValueError("j={} is not valid.".format(j))
# Computing gradient is not supported in forward mode, unless there is only one input.
if j is None and self.dim_x > 1:
raise NotImplementedError(
"Forward-mode autodiff doesn't support computing gradient."
)
if j is None:
if self.dim_x == 1:
j = 0
else:
raise NotImplementedError(
"Forward-mode autodiff doesn't support computing gradient."
)
# Compute J[:, j]
if j not in self.J:
if backend_name == "jax":
Expand Down

0 comments on commit e505ac1

Please sign in to comment.