Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dde.gradients support 3D outputs #1928

Open
wants to merge 227 commits into
base: master
Choose a base branch
from
Open

Conversation

Jerry-Jzy
Copy link
Contributor

No description provided.

Jerry-Jzy and others added 30 commits May 27, 2022 16:39
Update example of heat equation (lululxvi#706)
Add document for Lorenz inverse with exogenous input (lululxvi#709)
OperatorPredictor supports backends tensorflow.compat.v1, tensorflow,…
@lululxvi
Copy link
Owner

lululxvi commented Jan 3, 2025

This PR should only modify dde.gradients, not pde_operator.py.

@Jerry-Jzy Jerry-Jzy closed this Jan 3, 2025
@Jerry-Jzy Jerry-Jzy reopened this Jan 5, 2025
@lululxvi
Copy link
Owner

lululxvi commented Jan 5, 2025

You need to test all backends.

@Jerry-Jzy
Copy link
Contributor Author

You need to test all backends.

The only case where the output is 3D is shown to be supported only by tensorflow v2 and pytorch

https://github.com/lululxvi/deepxde/blob/master/examples/operator/stokes_aligned_pideeponet.py

@lululxvi
Copy link
Owner

lululxvi commented Jan 5, 2025

Not necessary testing PI-DeepONet. You can manually construct a function, and jus test if dde.gradients works correctly.

@Jerry-Jzy
Copy link
Contributor Author

Not necessary testing PI-DeepONet. You can manually construct a function, and jus test if dde.gradients works correctly.

I have tested pytorch, tf v2, paddle, jax. I don't have access to the environment for tf v1

When `ys` has shape (batch_size, dim_y), the output shape is (batch_size, 1).
When `ys` has shape (batch_size_out, batch_size, dim_y), the output shape is
(batch_size_out, batch_size, 1) if forward-mode autodiff is used or
(batch_size, 1) if reverse-mode autodiff is used.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reverse-mode, if it is (batch_size, 1), then does it mean that reverse mode doesn't support batch_size_out?

Copy link
Contributor Author

@Jerry-Jzy Jerry-Jzy Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverse mode does support batch_size_out. In reverse mode, the gradient has the same shape as the input since it uses vector jacobian product. so when the ys has the shape (batch_size, dim_y), the shape of gradient is (batch_size, 1) no matter reverse_mode or forward-mode is used.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. If revise-mode supports batch_size_out, then why the output is (batch_size, 1)? Where is batch_size_out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverse-mode support ys shape has the shape (batch_size_out, batch_size, dim_y) and xs has the shape (batch_size, dim_x). That's this PR care about, 3D output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants