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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9a7e38b
Tensorflow 1.x backend: multiple outputs extension of DeepONet
vl-dud Jul 31, 2023
ae48af0
Codacy Pylint fix
vl-dud Aug 3, 2023
76b7964
move vanilla deeponet building into a separate method
vl-dud Aug 4, 2023
c0e06a5
Remove unwanted method
vl-dud Aug 23, 2023
8338b81
Change `output_count` to `num_outputs`; format via Black
vl-dud Aug 26, 2023
1515c4b
add DeepONet building strategies
vl-dud Sep 15, 2023
ba8d2a0
Add docs for the strategy argument
vl-dud Sep 18, 2023
5087fc2
Format comments
vl-dud Sep 18, 2023
44dae05
Use maximum 88 characters per line
vl-dud Sep 18, 2023
4f23bf8
rename merge to merge_branch_trunk
vl-dud Sep 20, 2023
6f75d99
rename merge to merge_branch_trunk
vl-dud Oct 3, 2023
367905f
Change default deeponet strategy
vl-dud Oct 4, 2023
1d233c8
Change strategy to multi_output_strategy
vl-dud Oct 9, 2023
9fe3572
Codacy Pylint fix
vl-dud Oct 9, 2023
cb2b3fc
Update deeponet.py for tf2 multiple outputs
mitchelldaneker Oct 9, 2023
e7b7e5d
Update deeponet.py
mitchelldaneker Oct 10, 2023
9f41776
Update deeponet.py
mitchelldaneker Oct 10, 2023
97c3641
Add files via upload
mitchelldaneker Oct 10, 2023
85e5984
Update triple.py
mitchelldaneker Oct 10, 2023
b33f812
Merge remote-tracking branch 'origin/master' into deeponet-multiple-o…
vl-dud Oct 13, 2023
25bf219
Add DeepONet strategy classes to __init__.py
vl-dud Oct 13, 2023
44bfd0a
Update __init__.py
mitchelldaneker Oct 13, 2023
d11ab3a
Update deeponet.py
mitchelldaneker Oct 13, 2023
10ed010
Update __init__.py
mitchelldaneker Oct 13, 2023
3ccd772
Update deeponet.py
mitchelldaneker Oct 13, 2023
64ab358
Update antiderivative_aligned_UQ.py
mitchelldaneker Oct 13, 2023
68b2733
Update deeponet.py
mitchelldaneker Oct 13, 2023
569f94e
Revert "Add DeepONet strategy classes to __init__.py"
vl-dud Oct 16, 2023
7c4f750
Hide deeponet strategy classes
vl-dud Oct 16, 2023
ee3eccc
Update triple.py
mitchelldaneker Oct 16, 2023
91a07e9
Update deeponet.py
mitchelldaneker Oct 16, 2023
1eda936
Merge pull request #3 from mitchelldaneker/multiple-outputs-deeponet-tf2
vl-dud Oct 19, 2023
4c8c40e
Format a code with Black
vl-dud Oct 19, 2023
bed66e0
Codacy Pylint fix
vl-dud Oct 19, 2023
7d938c5
Codacy Pylint fix
vl-dud Oct 19, 2023
509f42c
Update triple.py
mitchelldaneker Oct 19, 2023
5f67bdd
Update deeponet.py
mitchelldaneker Oct 19, 2023
b9bf993
Update triple.py
mitchelldaneker Oct 19, 2023
5d66929
Update deeponet.py
mitchelldaneker Oct 20, 2023
f3bb8d2
Update deeponet.py
mitchelldaneker Oct 20, 2023
8102950
Update deeponet.py
mitchelldaneker Oct 20, 2023
54662db
Merge pull request #6 from mitchelldaneker/tf_multiple_outputs
vl-dud Oct 20, 2023
2459f80
Update deeponet.py
mitchelldaneker Oct 20, 2023
b79e0e0
Update triple.py
mitchelldaneker Oct 20, 2023
226ddac
Merge pull request #7 from mitchelldaneker/tf2_multiple_outputs
vl-dud Oct 20, 2023
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
3 changes: 1 addition & 2 deletions deepxde/data/pde_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ def _losses(self, outputs, loss_fn, inputs, model, num_func):

losses = []
for i in range(num_func):
out = outputs[i][:, None]

out = outputs[i] if model.net.num_outputs > 1 else outputs[i][:, None]
f = []
if self.pde.pde is not None:
f = self.pde.pde(inputs[1], out, model.net.auxiliary_vars[i][:, None])
Expand Down
14 changes: 13 additions & 1 deletion deepxde/data/triple.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def __init__(self, X_train, y_train, X_test, y_test):
self.train_sampler = BatchSampler(len(self.train_y), shuffle=True)

def losses(self, targets, outputs, loss_fn, inputs, model, aux=None):
if isinstance(loss_fn, list):
losses = []
for fn in loss_fn:
losses.append(fn(targets, outputs))
return losses
return loss_fn(targets, outputs)

def train_next_batch(self, batch_size=None):
Expand Down Expand Up @@ -74,14 +79,21 @@ def __init__(self, X_train, y_train, X_test, y_test):
self.trunk_sampler = BatchSampler(len(X_train[1]), shuffle=True)

def losses(self, targets, outputs, loss_fn, inputs, model, aux=None):
if isinstance(loss_fn, list):
losses = []
for fn in loss_fn:
losses.append(fn(targets, outputs))
return losses
return loss_fn(targets, outputs)

def train_next_batch(self, batch_size=None):
if batch_size is None:
return self.train_x, self.train_y
if not isinstance(batch_size, (tuple, list)):
indices = self.branch_sampler.get_next(batch_size)
return (self.train_x[0][indices], self.train_x[1]), self.train_y[indices]
return (self.train_x[0][indices], self.train_x[1]), self.train_y[
indices
]
indices_branch = self.branch_sampler.get_next(batch_size[0])
indices_trunk = self.trunk_sampler.get_next(batch_size[1])
return (
Expand Down
9 changes: 8 additions & 1 deletion deepxde/nn/tensorflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"""Package for tensorflow NN modules."""

__all__ = ["DeepONet", "DeepONetCartesianProd", "FNN", "NN", "PFNN", "PODDeepONet"]
__all__ = [
"DeepONet",
"DeepONetCartesianProd",
"FNN",
"NN",
"PFNN",
"PODDeepONet",
]

from .deeponet import DeepONet, DeepONetCartesianProd, PODDeepONet
from .fnn import FNN, PFNN
Expand Down
Loading