Skip to content

Commit 5678361

Browse files
committed
📌 update README
1 parent 37cb93b commit 5678361

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

‎README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A Package that provides Layers for the learning of (nonlinear) operators in orde
1414

1515
For now, this package contains the Fourier Neural Operator originally proposed by Li et al [1] as well as the DeepONet conceived by Lu et al [2].
1616

17-
I decided to implement this method in Julia because coding up a layer using PyTorch in Python is rather cumbersome in comparison and Julia as a whole simply runs at comparable or faster speed than Python. Please do check out the [original work](https://github.com/zongyi-li/fourier_neural_operator) at GitHub as well.
17+
I decided to implement this method in Julia because coding up a layer using PyTorch in Python is rather cumbersome in comparison and Julia as a whole simply runs at comparable or faster speed than Python.
1818

1919
The implementation of the layers is influenced heavily by the basic layers provided in the [Flux.jl](https://github.com/FluxML/Flux.jl) package.
2020

@@ -28,6 +28,8 @@ pkg> add OperatorLearning
2828

2929
## Usage/Examples
3030

31+
### Fourier Layer
32+
3133
The basic workflow is more or less in line with the layer architectures that `Flux` provides, i.e. you construct individual layers, chain them if desired and pass the inputs as arguments to the layers.
3234

3335
The Fourier Layer performs a linear transform as well as convolution (linear transform in fourier space), adds them and passes it through the activation.
@@ -47,11 +49,34 @@ model = FourierLayer(101, 101, 100, 16, σ)
4749
model = FourierLayer(101, 101, 100, 16, σ; bias_fourier=false)
4850
```
4951

50-
To see a full implementation, check the Burgers equation example at `examples/burgers.jl`.
52+
To see a full implementation, check the Burgers equation example at `examples/burgers_FNO.jl`.
5153
Compared to the original implementation by [Li et al.](https://github.com/zongyi-li/fourier_neural_operator/blob/master/fourier_1d.py) using PyTorch, this version written in Julia clocks in about 20 - 25% faster when running on a NVIDIA RTX A5000 GPU.
5254

5355
If you'd like to replicate the example, you need to get the dataset for learning the Burgers equation. You can get it [here](https://drive.google.com/drive/folders/1UnbQh2WWc6knEHbLn-ZaXrKUZhp7pjt-) or alternatively use the provided [scripts](https://github.com/zongyi-li/fourier_neural_operator/tree/master/data_generation/burgers).
5456

57+
### DeepONet
58+
59+
The `DeepONet` function basically sets up two separate Flux `Chain` structs and transforms the two input arrays into one via einsum/dot product.
60+
61+
You can either set up a "vanilla" DeepONet via the constructor function which sets up `Dense` layers for you or, if you feel fancy, pass two Chains directly to the function so you can use other architectures such as CNN or RNN as well.
62+
The former takes two tuples that describe each architecture. E.g. `(32,64,72)` sets up a DNN with 32 neurons in the first, 64 in the second and 72 in the last layer.
63+
64+
```julia
65+
using OperatorLearning
66+
using Flux
67+
68+
# Create a DeepONet with branch 32 -> 64 -> 72 and sigmoid activation
69+
# and trunk 24 -> 64 -> 72 and tanh activation without biases
70+
model = DeepONet((32,64,72), (24,64,72), σ, tanh; init_branch=Flux.glorot_normal, bias_trunk=false)
71+
72+
# Alternatively, set up your own nets altogether and pass them to DeepONet
73+
branch = Chain(Dense(2,128),Dense(128,64),Dense(64,72))
74+
trunk = Chain(Dense(1,24),Dense(24,72))
75+
model = DeepONet(branch,trunk)
76+
```
77+
78+
For usage, check the Burgers equation example at `examples/burgers_DeepONet.jl`.
79+
5580
## License
5681

5782
[MIT](https://choosealicense.com/licenses/mit/)
@@ -60,7 +85,7 @@ If you'd like to replicate the example, you need to get the dataset for learning
6085

6186
- [x] 1D Fourier Layer
6287
- [ ] 2D / 3D Fourier Layer
63-
- [ ] DeepONet
88+
- [x] DeepONet
6489
- [ ] Physics informed Loss
6590

6691
## Contributing
@@ -70,4 +95,5 @@ Contributions are always welcome! Please submit a PR if you'd like to participat
7095
## References
7196

7297
[1] Z. Li et al., „Fourier Neural Operator for Parametric Partial Differential Equations“, [arXiv:2010.08895](https://arxiv.org/abs/2010.08895) [cs, math], May 2021
98+
7399
[2] L. Lu, P. Jin, and G. E. Karniadakis, „DeepONet: Learning nonlinear operators for identifying differential equations based on the universal approximation theorem of operators“, [arXiv:1910.03193](http://arxiv.org/abs/1910.03193) [cs, stat], Apr. 2020

0 commit comments

Comments
 (0)