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

Tensorflow 1.x backend: multiple outputs extension of DeepONet #1410

Closed
wants to merge 45 commits into from

Conversation

vl-dud
Copy link
Contributor

@vl-dud vl-dud commented Jul 31, 2023

This pull request suggests an enhancement to DeepONet, addressing its current limitation of producing only a scalar output, which restricts its applicability in various tasks. The functionality of handling multiple outputs has been added to both the DeepONet and DeepONetCartesianProd classes. This extension is currently implemented solely for the TensorFlow 1.x backend. Also the PR includes an example of usage for a Poisson-like 2D problem.

@lululxvi
Copy link
Owner

lululxvi commented Aug 3, 2023

There are different ways for multiple outputs. Can you describe how you implement it?

@vl-dud
Copy link
Contributor Author

vl-dud commented Aug 4, 2023

I chose the method presented in the article https://arxiv.org/abs/2106.05384

The formula (1)
vanilla_deeponet
is replaced by (2)
modified_deeponet
for i = 1, . . . , n. n is the number of outputs.

Thereby the original implementation of formula (1) has been extracted into a method _build_vanilla_deeponet. _build_vanilla_deeponet is now invoked the necessary number of times, aligning with the number of outputs:

if self.output_count == 1:
    self.y = self._build_vanilla_deeponet()
else:
    ys = []
    for _ in range(0, self.output_count):
        ys.append(self._build_vanilla_deeponet())
    self.y = tf.stack(ys, axis=2)

@lululxvi
Copy link
Owner

lululxvi commented Aug 4, 2023

In https://doi.org/10.1016/j.cma.2022.114778, we introduced a few ways for multiple outputs. But it is unclear yet which one is better.

@vl-dud
Copy link
Contributor Author

vl-dud commented Aug 4, 2023

My implementation closely resembles the first option outlined in section 3.1.6:

  1. The simplest approach is that we can directly use n independent DeepONets, and each DeepONet outputs only one function.

It may be worth considering a future enhancement where all methods are implemented, allowing users to choose approach using a parameter in init().

@vl-dud
Copy link
Contributor Author

vl-dud commented Sep 15, 2023

@lululxvi I have added the approaches described in https://doi.org/10.1016/j.cma.2022.114778

@vl-dud
Copy link
Contributor Author

vl-dud commented Oct 19, 2023

@mitchelldaneker I merged your branch but there are some issues identified by Codacy. Please check https://app.codacy.com/gh/lululxvi/deepxde/pullRequest?prid=12314151

@mitchelldaneker
Copy link
Contributor

mitchelldaneker commented Oct 19, 2023

@mitchelldaneker I merged your branch but there are some issues identified by Codacy. Please check https://app.codacy.com/gh/lululxvi/deepxde/pullRequest?prid=12314151

I have made changes addressing these issues via a new pull request. Please take a look. I moved the input transform and output transform into the DeepONet call functions and out of the DeepONetStrategy call functions. I have also fixed an unresolved issue I missed in the triple.py file for multiple losses.

mitchelldaneker and others added 10 commits October 19, 2023 11:22
add in older fixes
wrong file change, fixed
Fix codacy errors in tf2_multiple_outputs
fix extra input to call function
removed unused args
Tf2 multiple outputs fix codacy errors of extra inputs and unused imports
@vl-dud
Copy link
Contributor Author

vl-dud commented Oct 20, 2023

@lululxvi the code is now ready for your review

@lululxvi
Copy link
Owner

This PR becomes very long now and hard to review. Is it possible to split this PR into a few smaller ones?

@vl-dud vl-dud closed this Oct 23, 2023
@vl-dud
Copy link
Contributor Author

vl-dud commented Oct 23, 2023

Divided into #1532 and #1533

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.

3 participants