-
Notifications
You must be signed in to change notification settings - Fork 774
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
Add an example of Poisson-like 2D problem for multioutput DeepONet Add the example #1549
Open
vl-dud
wants to merge
3
commits into
lululxvi:master
Choose a base branch
from
vl-dud:deeponet-multioutput-poisson-example
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
examples/operator/poisson_aligned_multioutput_pideeponet_2d.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
""" | ||
Poisson-like 2D problem | ||
Supported backend: tensorflow.compat.v1, tensorflow | ||
""" | ||
import numpy as np | ||
|
||
import deepxde as dde | ||
|
||
|
||
# Two target variables: A and B | ||
# Equations: dA_xx = f, dB_tt = f | ||
def equation(x, y, f): | ||
# A = y[:, 0:1] and B = y[:, 1:2] | ||
dA_xx = dde.grad.hessian(y, x, component=0, i=0, j=0) | ||
dB_tt = dde.grad.hessian(y, x, component=1, i=1, j=1) | ||
return [dA_xx - f, dB_tt - f] | ||
|
||
|
||
# Define space/time geometry | ||
geomtime = dde.geometry.GeometryXTime( | ||
dde.geometry.Interval(0, 1), dde.geometry.TimeDomain(0, 1) | ||
) | ||
|
||
# Boundary conditions for A and B | ||
A_bc = dde.icbc.DirichletBC( | ||
geomtime, | ||
lambda _: 0, | ||
lambda _, on_boundary: on_boundary and np.isclose(_[0], 0), | ||
component=0, | ||
) | ||
B_bc = dde.icbc.DirichletBC( | ||
geomtime, | ||
lambda _: 0, | ||
lambda _, on_boundary: on_boundary and np.isclose(_[0], 1), | ||
component=1, | ||
) | ||
|
||
space = dde.data.GRF2D() | ||
evaluation_points = geomtime.uniform_points(10) | ||
|
||
data = dde.data.PDEOperatorCartesianProd( | ||
dde.data.TimePDE( | ||
geomtime, equation, [A_bc, B_bc], num_domain=1000, num_boundary=10 | ||
), | ||
space, | ||
evaluation_points, | ||
num_function=10, | ||
) | ||
|
||
# Define DeepONet with two outputs. | ||
# Use `split_branch` strategy. The output size of the trunk net is equal | ||
# to the output size of the branch net divided by the number of outputs. | ||
net = dde.nn.DeepONetCartesianProd( | ||
[evaluation_points.shape[0], 100, 100], | ||
[geomtime.dim, 100, 50], | ||
activation="tanh", | ||
kernel_initializer="Glorot normal", | ||
num_outputs=2, | ||
multi_output_strategy="split_branch", | ||
) | ||
|
||
# Train model | ||
model = dde.Model(data, net) | ||
model.compile("adam", lr=0.001) | ||
model.train(iterations=5000) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this is also a fake problem used for demonstration. The equations are of the form
dA_xx = f
anddB_tt = f
, wheredA_xx
anddB_tt
are the second-order derivatives of some A and B with respect to spatial and temporal dimensions, respectively.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm. Is it possible to have a real example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but the suitable real problem does not come to mind. Do you have any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A 2D fluid problem with outputs of u and v?