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

Commit c468c99

Browse files
Merge pull request #116 from ArnoStrouwen/md
format markdown
2 parents 6c2cd97 + 6ef9b7f commit c468c99

File tree

15 files changed

+159
-124
lines changed

15 files changed

+159
-124
lines changed

.JuliaFormatter.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
style = "sciml"
2+
format_markdown = true

README.md

+29-28
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
[![Build Status](https://github.com/SciML/NeuralOperators.jl/workflows/CI/badge.svg)](https://github.com/SciML/NeuralOperators.jl/actions?query=workflow%3ACI)
88
[![Build status](https://badge.buildkite.com/be853055db9e309317157b7e2983e752b60705502e622a139e.svg?branch=main)](https://buildkite.com/julialang/neuraloperators-dot-jl)
99

10-
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
10+
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
1111
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
1212

13-
| **Ground Truth** | **Inferenced** |
14-
|:----------------:|:--------------:|
13+
| **Ground Truth** | **Inferenced** |
14+
|:-------------------------------------------:|:--------------------------------------------------:|
1515
| ![](example/FlowOverCircle/gallery/ans.gif) | ![](example/FlowOverCircle/gallery/inferenced.gif) |
1616

1717
The demonstration showing above is Navier-Stokes equation learned by the `MarkovNeuralOperator` with only one time step information.
@@ -44,35 +44,32 @@ It is important that the output size of the branch and trunk subnets is same so
4444

4545
```julia
4646
model = Chain(
47-
# lift (d + 1)-dimensional vector field to n-dimensional vector field
48-
# here, d == 1 and n == 64
49-
Dense(2, 64),
50-
# map each hidden representation to the next by integral kernel operator
51-
OperatorKernel(64=>64, (16, ), FourierTransform, gelu),
52-
OperatorKernel(64=>64, (16, ), FourierTransform, gelu),
53-
OperatorKernel(64=>64, (16, ), FourierTransform, gelu),
54-
OperatorKernel(64=>64, (16, ), FourierTransform),
55-
# project back to the scalar field of interest space
56-
Dense(64, 128, gelu),
57-
Dense(128, 1),
58-
)
47+
# lift (d + 1)-dimensional vector field to n-dimensional vector field
48+
# here, d == 1 and n == 64
49+
Dense(2, 64),
50+
# map each hidden representation to the next by integral kernel operator
51+
OperatorKernel(64 => 64, (16,), FourierTransform, gelu),
52+
OperatorKernel(64 => 64, (16,), FourierTransform, gelu),
53+
OperatorKernel(64 => 64, (16,), FourierTransform, gelu),
54+
OperatorKernel(64 => 64, (16,), FourierTransform),
55+
# project back to the scalar field of interest space
56+
Dense(64, 128, gelu),
57+
Dense(128, 1))
5958
```
6059

6160
Or one can just call:
6261

6362
```julia
64-
model = FourierNeuralOperator(
65-
ch=(2, 64, 64, 64, 64, 64, 128, 1),
66-
modes=(16, ),
67-
σ=gelu
68-
)
63+
model = FourierNeuralOperator(ch = (2, 64, 64, 64, 64, 64, 128, 1),
64+
modes = (16,),
65+
σ = gelu)
6966
```
7067

7168
And then train as a Flux model.
7269

7370
```julia
7471
loss(𝐱, 𝐲) = l₂loss(model(𝐱), 𝐲)
75-
opt = Flux.Optimiser(WeightDecay(1f-4), Flux.Adam(1f-3))
72+
opt = Flux.Optimiser(WeightDecay(1.0f-4), Flux.Adam(1.0f-3))
7673
Flux.@epochs 50 Flux.train!(loss, params(model), data, opt)
7774
```
7875

@@ -83,6 +80,7 @@ Flux.@epochs 50 Flux.train!(loss, params(model), data, opt)
8380
# followed by activations for branch and trunk respectively
8481
model = DeepONet((32, 64, 72), (24, 64, 72), σ, tanh)
8582
```
83+
8684
Or specify branch and trunk as separate `Chain` from Flux and pass to `DeepONet`
8785

8886
```julia
@@ -100,7 +98,7 @@ evalcb() = @show(loss(xval, yval, grid))
10098
learning_rate = 0.001
10199
opt = Adam(learning_rate)
102100
parameters = params(model)
103-
Flux.@epochs 400 Flux.train!(loss, parameters, [(xtrain, ytrain, grid)], opt, cb=evalcb)
101+
Flux.@epochs 400 Flux.train!(loss, parameters, [(xtrain, ytrain, grid)], opt, cb = evalcb)
104102
```
105103

106104
## Examples
@@ -129,9 +127,12 @@ PDE training examples are provided in `example` folder.
129127

130128
## References
131129

132-
- [Fourier Neural Operator for Parametric Partial Differential Equations](https://arxiv.org/abs/2010.08895)
133-
- [zongyi-li/fourier_neural_operator](https://github.com/zongyi-li/fourier_neural_operator)
134-
- [Neural Operator: Graph Kernel Network for Partial Differential Equations](https://arxiv.org/abs/2003.03485)
135-
- [zongyi-li/graph-pde](https://github.com/zongyi-li/graph-pde)
136-
- [Markov Neural Operators for Learning Chaotic Systems](https://arxiv.org/abs/2106.06898)
137-
- [DeepONet: Learning nonlinear operators for identifying differential equations based on the universal approximation theorem of operators](https://arxiv.org/abs/1910.03193)
130+
- [Fourier Neural Operator for Parametric Partial Differential Equations](https://arxiv.org/abs/2010.08895)
131+
132+
+ [zongyi-li/fourier_neural_operator](https://github.com/zongyi-li/fourier_neural_operator)
133+
134+
- [Neural Operator: Graph Kernel Network for Partial Differential Equations](https://arxiv.org/abs/2003.03485)
135+
136+
+ [zongyi-li/graph-pde](https://github.com/zongyi-li/graph-pde)
137+
- [Markov Neural Operators for Learning Chaotic Systems](https://arxiv.org/abs/2106.06898)
138+
- [DeepONet: Learning nonlinear operators for identifying differential equations based on the universal approximation theorem of operators](https://arxiv.org/abs/1910.03193)

docs/src/apis.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ OperatorConv
2727

2828
Reference: [FNO2021](@cite)
2929

30-
---
30+
* * *
3131

3232
### Operator kernel layer
3333

@@ -45,7 +45,7 @@ OperatorKernel
4545

4646
Reference: [FNO2021](@cite)
4747

48-
---
48+
* * *
4949

5050
### Graph kernel layer
5151

@@ -64,7 +64,7 @@ GraphKernel
6464

6565
Reference: [NO2020](@cite)
6666

67-
---
67+
* * *
6868

6969
## Models
7070

@@ -76,7 +76,7 @@ FourierNeuralOperator
7676

7777
Reference: [FNO2021](@cite)
7878

79-
---
79+
* * *
8080

8181
### Markov neural operator
8282

@@ -86,7 +86,7 @@ MarkovNeuralOperator
8686

8787
Reference: [MNO2021](@cite)
8888

89-
---
89+
* * *
9090

9191
### DeepONet
9292

@@ -95,7 +95,7 @@ DeepONet
9595
NeuralOperators.construct_subnet
9696
```
9797

98-
---
98+
* * *
9999

100100
### NOMAD
101101

docs/src/index.md

+55-21
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ CurrentModule = NeuralOperators
55
# NeuralOperators
66

77
| ![](https://github.com/foldfelis/NeuralOperators.jl/blob/main/example/FlowOverCircle/gallery/ans.gif?raw=true) | ![](https://github.com/foldfelis/NeuralOperators.jl/blob/main/example/FlowOverCircle/gallery/inferenced.gif?raw=true) |
8-
|:----------------:|:--------------:|
9-
| **Ground Truth** | **Inferred** |
8+
|:--------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------:|
9+
| **Ground Truth** | **Inferred** |
1010

1111
The demonstration shown above is the Navier-Stokes equation learned by the `MarkovNeuralOperator` with only one time step information.
1212
The example can be found in [`example/FlowOverCircle`](https://github.com/SciML/NeuralOperators.jl/tree/main/example/FlowOverCircle).
1313

14-
## Quick start
14+
## Installation
1515

16-
The package can be installed with the Julia package manager. From the Julia REPL, type `]` to enter the Pkg REPL mode and run:
16+
To install NeuralOperators.jl, use the Julia package manager:
17+
18+
```julia
19+
using Pkg
20+
Pkg.add("NeuralOperators")
21+
```
1722

18-
```julia-repl
19-
pkg> add NeuralOperators
2023
```
2124
2225
## Usage
@@ -42,18 +45,16 @@ model = Chain(
4245
Or one can just call:
4346

4447
```julia
45-
model = FourierNeuralOperator(
46-
ch=(2, 64, 64, 64, 64, 64, 128, 1),
47-
modes=(16, ),
48-
σ=gelu
49-
)
48+
model = FourierNeuralOperator(ch = (2, 64, 64, 64, 64, 64, 128, 1),
49+
modes = (16,),
50+
σ = gelu)
5051
```
5152

5253
And then train as a Flux model.
5354

5455
```julia
5556
loss(𝐱, 𝐲) = l₂loss(model(𝐱), 𝐲)
56-
opt = Flux.Optimiser(WeightDecay(1f-4), Flux.Adam(1f-3))
57+
opt = Flux.Optimiser(WeightDecay(1.0f-4), Flux.Adam(1.0f-3))
5758
Flux.@epochs 50 Flux.train!(loss, params(model), data, opt)
5859
```
5960

@@ -82,61 +83,94 @@ evalcb() = @show(loss(xval, yval, grid))
8283
learning_rate = 0.001
8384
opt = Adam(learning_rate)
8485
parameters = params(model)
85-
Flux.@epochs 400 Flux.train!(loss, parameters, [(xtrain, ytrain, grid)], opt, cb=evalcb)
86+
Flux.@epochs 400 Flux.train!(loss, parameters, [(xtrain, ytrain, grid)], opt, cb = evalcb)
8687
```
88+
8789
A more complete example using DeepONet architecture to solve Burgers' equation can be found in the [examples](https://github.com/SciML/NeuralOperators.jl/blob/main/example/Burgers/src/Burgers_deeponet.jl).
8890

91+
## Contributing
92+
93+
- Please refer to the
94+
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
95+
for guidance on PRs, issues, and other matters relating to contributing to SciML.
96+
97+
- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
98+
- There are a few community forums:
99+
100+
+ The #diffeq-bridged and #sciml-bridged channels in the
101+
[Julia Slack](https://julialang.org/slack/)
102+
+ The #diffeq-bridged and #sciml-bridged channels in the
103+
[Julia Zulip](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
104+
+ On the [Julia Discourse forums](https://discourse.julialang.org)
105+
+ See also [SciML Community page](https://sciml.ai/community/)
106+
89107
## Reproducibility
108+
90109
```@raw html
91110
<details><summary>The documentation of this SciML package was built using these direct dependencies,</summary>
92111
```
112+
93113
```@example
94114
using Pkg # hide
95115
Pkg.status() # hide
96116
```
117+
97118
```@raw html
98119
</details>
99120
```
121+
100122
```@raw html
101123
<details><summary>and using this machine and Julia version.</summary>
102124
```
125+
103126
```@example
104127
using InteractiveUtils # hide
105128
versioninfo() # hide
106129
```
130+
107131
```@raw html
108132
</details>
109133
```
134+
110135
```@raw html
111136
<details><summary>A more complete overview of all dependencies and their versions is also provided.</summary>
112137
```
138+
113139
```@example
114140
using Pkg # hide
115-
Pkg.status(;mode = PKGMODE_MANIFEST) # hide
141+
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
116142
```
143+
117144
```@raw html
118145
</details>
119146
```
147+
120148
```@raw html
121149
You can also download the
122150
<a href="
123151
```
152+
124153
```@eval
125154
using TOML
126-
version = TOML.parse(read("../../Project.toml",String))["version"]
127-
name = TOML.parse(read("../../Project.toml",String))["name"]
128-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Manifest.toml"
155+
version = TOML.parse(read("../../Project.toml", String))["version"]
156+
name = TOML.parse(read("../../Project.toml", String))["name"]
157+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
158+
"/assets/Manifest.toml"
129159
```
160+
130161
```@raw html
131162
">manifest</a> file and the
132163
<a href="
133164
```
165+
134166
```@eval
135167
using TOML
136-
version = TOML.parse(read("../../Project.toml",String))["version"]
137-
name = TOML.parse(read("../../Project.toml",String))["name"]
138-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Project.toml"
168+
version = TOML.parse(read("../../Project.toml", String))["version"]
169+
name = TOML.parse(read("../../Project.toml", String))["name"]
170+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
171+
"/assets/Project.toml"
139172
```
173+
140174
```@raw html
141175
">project</a> file.
142-
```
176+
```

example/Burgers/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
In this example, a [Burgers' equation](https://en.wikipedia.org/wiki/Burgers%27_equation)
44
is learned by a one-dimensional Fourier neural operator network.
55

6-
there is learn the operator mapping the initial condition to last point of time evolition of equation in some function space :
6+
there is learn the operator mapping the initial condition to last point of time evolition of equation in some function space :
77

88
```math
99
u(x, 0) -> u(x, t_end)\
1010
```
1111

12-
![](gallery/burgers.png)
12+
![](gallery/burgers.png)
1313

1414
Change directory to `example/Burgers` and use following commend to train model:
1515

1616
```julia
17+
julia> using Burgers;
18+
Burgers.train();
1719
$ julia --proj
18-
19-
julia> using Burgers; Burgers.train()
2020
```

example/DoublePendulum/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ By inference the result recurrently, we can generate up to 150 steps with the fi
1414
Change directory to `example/DoublePendulum` and use following commend to train model:
1515

1616
```julia
17+
julia> using DoublePendulum;
18+
DoublePendulum.train();
1719
$ julia --proj
18-
19-
julia> using DoublePendulum; DoublePendulum.train()
2020
```

example/FlowOverCircle/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
The time dependent Navier-Stokes equation is learned by the `MarkovNeuralOperator` with only one time step information.
44
The result of this example can be found [here](https://docs.sciml.ai/NeuralOperators/stable/assets/notebook/mno.jl.html).
55

6-
| **Ground Truth** | **Inferenced** |
7-
|:----------------:|:--------------:|
6+
| **Ground Truth** | **Inferenced** |
7+
|:--------------------:|:---------------------------:|
88
| ![](gallery/ans.gif) | ![](gallery/inferenced.gif) |
99

1010
Change directory to `example/FlowOverCircle` and use following commend to train model:
1111

1212
```julia
13+
julia> using FlowOverCircle;
14+
FlowOverCircle.train();
1315
$ julia --proj
14-
15-
julia> using FlowOverCircle; FlowOverCircle.train()
1616
```

example/SuperResolution/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ The result of this example can be found [here](https://docs.sciml.ai/NeuralOpera
55

66
Apart from just training a MNO, here, we train the model with lower resolution (96x64) and inference result with higher resolution (192x128).
77

8-
| **Ground Truth** | **Inferenced** |
9-
|:----------------:|:--------------:|
8+
| **Ground Truth** | **Inferenced** |
9+
|:--------------------:|:---------------------------:|
1010
| ![](gallery/ans.gif) | ![](gallery/inferenced.gif) |
1111

1212
Change directory to `example/SuperResolution` and use following commend to train model:
1313

1414
```julia
15+
julia> using SuperResolution;
16+
SuperResolution.train();
1517
$ julia --proj
16-
17-
julia> using SuperResolution; SuperResolution.train()
1818
```

0 commit comments

Comments
 (0)