You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-3Lines changed: 29 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ A Package that provides Layers for the learning of (nonlinear) operators in orde
14
14
15
15
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].
16
16
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.
18
18
19
19
The implementation of the layers is influenced heavily by the basic layers provided in the [Flux.jl](https://github.com/FluxML/Flux.jl) package.
20
20
@@ -28,6 +28,8 @@ pkg> add OperatorLearning
28
28
29
29
## Usage/Examples
30
30
31
+
### Fourier Layer
32
+
31
33
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.
32
34
33
35
The Fourier Layer performs a linear transform as well as convolution (linear transform in fourier space), adds them and passes it through the activation.
model =FourierLayer(101, 101, 100, 16, σ; bias_fourier=false)
48
50
```
49
51
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`.
51
53
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.
52
54
53
55
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).
54
56
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
For usage, check the Burgers equation example at `examples/burgers_DeepONet.jl`.
79
+
55
80
## License
56
81
57
82
[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
60
85
61
86
-[x] 1D Fourier Layer
62
87
-[ ] 2D / 3D Fourier Layer
63
-
-[] DeepONet
88
+
-[x] DeepONet
64
89
-[ ] Physics informed Loss
65
90
66
91
## Contributing
@@ -70,4 +95,5 @@ Contributions are always welcome! Please submit a PR if you'd like to participat
70
95
## References
71
96
72
97
[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
+
73
99
[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