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

Add an example of Poisson-like 2D problem for multioutput DeepONet Add the example #1549

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use split_branch strategy
  • Loading branch information
vl-dud committed Dec 24, 2023
commit 66001594fa6eb7b08df2151db3c039e334822756
18 changes: 7 additions & 11 deletions examples/operator/poisson_aligned_multioutput_pideeponet_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@
Poisson-like 2D problem
Supported backend: tensorflow.compat.v1, tensorflow
"""
Copy link
Owner

Choose a reason for hiding this comment

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

"""Supported backend: tensorflow.compat.v1, tensorflow

Poisson-like 2D problem ... More explanation...
"""

Copy link
Contributor Author

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 and dB_tt = f, where dA_xx and dB_tt are the second-order derivatives of some A and B with respect to spatial and temporal dimensions, respectively.

Copy link
Owner

@lululxvi lululxvi Dec 25, 2023

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?

Copy link
Contributor Author

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?

Copy link
Owner

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?

import os

os.environ["DDEBACKEND"] = "tensorflow.compat.v1"

import numpy as np
import deepxde as dde
from deepxde.backend import tf
import matplotlib.pyplot as plt

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]
B = y[:, 1:2]
# 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]
Expand Down Expand Up @@ -54,13 +47,16 @@ def equation(x, y, f):
num_function=10,
)

# Define DeepONet with two outputs
# 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, 100],
[geomtime.dim, 100, 50],
activation="tanh",
kernel_initializer="Glorot normal",
num_outputs=2,
multi_output_strategy="split_branch",
)

# Train model
Expand Down