Skip to content
This repository was archived by the owner on Sep 28, 2024. It is now read-only.

Commit 1e9b134

Browse files
committed
Updated tests and readme
1 parent c1a70d1 commit 1e9b134

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ It performs Fourier transformation across infinite-dimensional function spaces a
3636
With only one time step information of learning, it can predict the following few steps with low loss
3737
by linking the operators into a Markov chain.
3838

39+
**DeepONet operator** (Deep Operator Network)learns a neural operator with the help of two sub-neural net structures described as the branch and the trunk network. The branch network is fed the initial conditions data, whereas the trunk is fed with the locations where the target(output) is evaluated from the corresponding initial conditions. It is important that the output size of the branch and trunk subnets is same so that a dot product can be performed between them.
40+
3941
Currently, the `FourierOperator` layer is provided in this work.
4042
As for model, there are `FourierNeuralOperator` and `MarkovNeuralOperator` provided. Please take a glance at them [here](src/model.jl).
4143

4244
## Usage
4345

46+
Fourier Neural Operator
47+
4448
```julia
4549
model = Chain(
4650
# lift (d + 1)-dimensional vector field to n-dimensional vector field
@@ -76,6 +80,14 @@ opt = Flux.Optimiser(WeightDecay(1f-4), Flux.ADAM(1f-3))
7680
Flux.@epochs 50 Flux.train!(loss, params(model), data, opt)
7781
```
7882

83+
DeepONet
84+
85+
```julia
86+
#tuple of Ints for branch net architecture and then for trunk net, followed by activations for branch and trunk respectively
87+
model = DeepONet((32,64,72), (24,64,72), σ, tanh)
88+
```
89+
You can again specify loss, optimization and training parameters just as you would for a simple neural network with Flux.
90+
7991
## Examples
8092

8193
PDE training examples are provided in `example` folder.
@@ -113,3 +125,4 @@ PDE training examples are provided in `example` folder.
113125
- [Neural Operator: Graph Kernel Network for Partial Differential Equations](https://arxiv.org/abs/2003.03485)
114126
- [zongyi-li/graph-pde](https://github.com/zongyi-li/graph-pde)
115127
- [Markov Neural Operators for Learning Chaotic Systems](https://arxiv.org/abs/2106.06898)
128+
- [DeepONet: Learning nonlinear operators for identifying differential equations based on the universal approximation theorem of operators](https://arxiv.org/abs/1910.03193)

test/deeponet.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ mgrad = Flux.Zygote.gradient((x,p)->sum(model(x,p)),a,sensors)
3333
@test !iszero(Flux.Zygote.gradient((x,p)->sum(model(x,p)),a,sensors)[1])
3434
@test !iszero(Flux.Zygote.gradient((x,p)->sum(model(x,p)),a,sensors)[2])
3535

36-
#training
36+
#Output size of branch and trunk subnets should be same
37+
branch = Chain(Dense(16, 22), Dense(22, 30))
38+
trunk = Chain(Dense(1, 16), Dense(16, 24), Dense(24, 32))
39+
m = DeepONet(branch, trunk)
40+
@test_throws AssertionError DeepONet((32,64,70), (24,48,72), σ, tanh)
41+
@test_throws DimensionMismatch m(a, sensors)

0 commit comments

Comments
 (0)