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

Commit 153130e

Browse files
authored
Merge pull request #21 from foldfelis/doc
Doc
2 parents f502087 + fedb283 commit 153130e

File tree

6 files changed

+231
-29
lines changed

6 files changed

+231
-29
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@
1212
[codecov badge]: https://codecov.io/gh/foldfelis/NeuralOperators.jl/branch/master/graph/badge.svg?token=JQH3MP1Y9R
1313
[codecov link]: https://codecov.io/gh/foldfelis/NeuralOperators.jl
1414

15-
Neural operator is a novel deep learning architecture. It learns a operator, which is a mapping
16-
between infinite-dimensional function spaces. It can be used to resolve [partial differential equations (PDE)](https://en.wikipedia.org/wiki/Partial_differential_equation).
17-
Instead of solving by finite element method, a PDE problem can be resolved by learning a neural network to learn an operator
18-
mapping from infinite-dimensional space (u, t) to infinite-dimensional space f(u, t). Neural operator learns a continuous function
19-
between two continuous function spaces. The kernel can be trained on different geometry, which is learned from a graph.
15+
Neural operator is a novel deep learning architecture.
16+
It learns a operator, which is a mapping between infinite-dimensional function spaces.
17+
It can be used to resolve [partial differential equations (PDE)](https://en.wikipedia.org/wiki/Partial_differential_equation).
18+
Instead of solving by finite element method, a PDE problem can be resolved by training a neural network to learn an operator mapping
19+
from infinite-dimensional space (u, t) to infinite-dimensional space f(u, t).
20+
Neural operator learns a continuous function between two continuous function spaces.
21+
The kernel can be trained on different geometry, which is learned from a graph.
2022

21-
Fourier neural operator learns a neural operator with Dirichlet kernel to form a Fourier transformation. It performs Fourier transformation across infinite-dimensional function spaces and learns better than neural operator.
23+
**Fourier neural operator** learns a neural operator with Dirichlet kernel to form a Fourier transformation.
24+
It performs Fourier transformation across infinite-dimensional function spaces and learns better than neural operator.
25+
26+
**Markov neural operator** learns a neural operator with Fourier operators.
27+
With only one time step information of learning, it can predict the following few steps with low loss
28+
by linking the operators into a Markov chain.
2229

2330
Currently, the `FourierOperator` layer is provided in this work.
2431
As for model, there are `FourierNeuralOperator` and `MarkovNeuralOperator` provided. Please take a glance at them [here](src/model.jl).
@@ -41,7 +48,7 @@ model = Chain(
4148
)
4249
```
4350

44-
Or you can just call:
51+
Or one can just call:
4552

4653
```julia
4754
model = FourierNeuralOperator(
@@ -106,3 +113,4 @@ julia> using FlowOverCircle; FlowOverCircle.train()
106113
- [zongyi-li/fourier_neural_operator](https://github.com/zongyi-li/fourier_neural_operator)
107114
- [Neural Operator: Graph Kernel Network for Partial Differential Equations](https://arxiv.org/abs/2003.03485)
108115
- [zongyi-li/graph-pde](https://github.com/zongyi-li/graph-pde)
116+
- [Markov Neural Operators for Learning Chaotic Systems](https://arxiv.org/abs/2106.06898)

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ makedocs(;
1515
),
1616
pages=[
1717
"Home" => "index.md",
18+
"APIs" => "apis.md"
1819
],
1920
)
2021

docs/src/apis.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
## Index
2+
3+
```@index
4+
```
5+
6+
## Layers
7+
8+
### Spectral convolutional layer
9+
10+
```math
11+
F(s) = \mathcal{F} \{ v(x) \} \\
12+
F'(s) = g(F(s)) \\
13+
v'(x) = \mathcal{F}^{-1} \{ F'(s) \}
14+
```
15+
16+
where ``v(x)`` and ``v'(x)`` denotes input and output function,
17+
``\mathcal{F} \{ \cdot \}``, ``\mathcal{F}^{-1} \{ \cdot \}`` are Fourier transform, inverse Fourier transform, respectively.
18+
Function ``g`` is a linear transform for lowering Fouier modes.
19+
20+
```@docs
21+
SpectralConv
22+
```
23+
24+
Reference: [Fourier Neural Operator for Parametric Partial Differential Equations](https://arxiv.org/abs/2010.08895)
25+
26+
---
27+
28+
### Fourier operator layer
29+
30+
```math
31+
v_{t+1}(x) = \sigma(W v_t(x) + \mathcal{K} \{ v_t(x) \} )
32+
```
33+
34+
where ``v_t(x)`` is the input function for ``t``-th layer and ``\mathcal{K} \{ \cdot \}`` denotes spectral convolutional layer.
35+
Activation function ``\sigma`` can be arbitrary non-linear function.
36+
37+
```@docs
38+
FourierOperator
39+
```
40+
41+
Reference: [Fourier Neural Operator for Parametric Partial Differential Equations](https://arxiv.org/abs/2010.08895)
42+
43+
## Models
44+
45+
### Fourier neural operator
46+
47+
```@docs
48+
FourierNeuralOperator
49+
```
50+
51+
Reference: [Fourier Neural Operator for Parametric Partial Differential Equations](https://arxiv.org/abs/2010.08895)
52+
53+
---
54+
55+
### Markov neural operator
56+
57+
```@docs
58+
MarkovNeuralOperator
59+
```
60+
61+
Reference: [Markov Neural Operators for Learning Chaotic Systems](https://arxiv.org/abs/2106.06898)

docs/src/assets/notebook/mno.jl.html

Lines changed: 75 additions & 0 deletions
Large diffs are not rendered by default.

docs/src/index.md

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,75 @@ CurrentModule = NeuralOperators
66

77
Documentation for [NeuralOperators](https://github.com/foldfelis/NeuralOperators.jl).
88

9-
```@index
10-
```
9+
| **Ground Truth** | **Inferenced** |
10+
|:----------------:|:--------------:|
11+
| ![](https://github.com/foldfelis/NeuralOperators.jl/blob/master/example/FlowOverCircle/gallery/ans.gif?raw=true) | ![](https://github.com/foldfelis/NeuralOperators.jl/blob/master/example/FlowOverCircle/gallery/ans.gif?raw=true) |
1112

12-
## Layers
13+
The demonstration showing above is Navier-Stokes equation learned by the `MarkovNeuralOperator` with only one time step information.
14+
Example can be found in [`example/FlowOverCircle`](https://github.com/foldfelis/NeuralOperators.jl/tree/master/example/FlowOverCircle).
15+
The result is also provided [here](assets/notebook/mno.jl.html)
1316

14-
### Spectral convolutional layer
17+
## Abstract
1518

16-
```math
17-
F(s) = \mathcal{F} \{ v(x) \} \\
18-
F'(s) = g(F(s)) \\
19-
v'(x) = \mathcal{F}^{-1} \{ F'(s) \}
20-
```
19+
Neural operator is a novel deep learning architecture.
20+
It learns a operator, which is a mapping between infinite-dimensional function spaces.
21+
It can be used to resolve [partial differential equations (PDE)](https://en.wikipedia.org/wiki/Partial_differential_equation).
22+
Instead of solving by finite element method, a PDE problem can be resolved by training a neural network to learn an operator mapping
23+
from infinite-dimensional space (u, t) to infinite-dimensional space f(u, t).
24+
Neural operator learns a continuous function between two continuous function spaces.
25+
The kernel can be trained on different geometry, which is learned from a graph.
2126

22-
where ``v(x)`` and ``v'(x)`` denotes input and output function, ``\mathcal{F} \{ \cdot \}``, ``\mathcal{F}^{-1} \{ \cdot \}`` are Fourier transform, inverse Fourier transform, respectively. Function ``g`` is a linear transform for lowering Fouier modes.
27+
**Fourier neural operator** learns a neural operator with Dirichlet kernel to form a Fourier transformation.
28+
It performs Fourier transformation across infinite-dimensional function spaces and learns better than neural operator.
2329

24-
```@docs
25-
SpectralConv
26-
```
30+
**Markov neural operator** learns a neural operator with Fourier operators.
31+
With only one time step information of learning, it can predict the following few steps with low loss
32+
by linking the operators into a Markov chain.
33+
34+
Currently, the `FourierOperator` layer is provided in this work.
35+
As for model, there are `FourierNeuralOperator` and `MarkovNeuralOperator` provided.
36+
Please take a glance at them [here](apis.html#Models).
2737

28-
Reference: [Fourier Neural Operator for Parametric Partial Differential Equations](https://arxiv.org/abs/2010.08895)
38+
## Quick start
2939

30-
---
40+
The package can be installed with the Julia package manager. From the Julia REPL, type `]` to enter the Pkg REPL mode and run:
3141

32-
### Fourier operator layer
42+
```julia-repl
43+
pkg> add NeuralOperators
44+
```
45+
46+
## Usage
3347

34-
```math
35-
v_{t+1}(x) = \sigma(W v_t(x) + \mathcal{K} \{ v_t(x) \} )
48+
```julia
49+
model = Chain(
50+
# project finite-dimensional data to infinite-dimensional space
51+
Dense(2, 64),
52+
# operator projects data between infinite-dimensional spaces
53+
FourierOperator(64=>64, (16, ), gelu),
54+
FourierOperator(64=>64, (16, ), gelu),
55+
FourierOperator(64=>64, (16, ), gelu),
56+
FourierOperator(64=>64, (16, )),
57+
# project infinite-dimensional function to finite-dimensional space
58+
Dense(64, 128, gelu),
59+
Dense(128, 1),
60+
flatten
61+
)
3662
```
3763

38-
where ``v_t(x)`` is the input function for ``t``-th layer and ``\mathcal{K} \{ \cdot \}`` denotes spectral convolutional layer. Activation function ``\sigma`` can be arbitrary non-linear function.
64+
Or one can just call:
3965

40-
```@docs
41-
FourierOperator
66+
```julia
67+
model = FourierNeuralOperator(
68+
ch=(2, 64, 64, 64, 64, 64, 128, 1),
69+
modes=(16, ),
70+
σ=gelu
71+
)
4272
```
4373

44-
Reference: [Fourier Neural Operator for Parametric Partial Differential Equations](https://arxiv.org/abs/2010.08895)
74+
And then train as a Flux model.
75+
76+
```julia
77+
loss(𝐱, 𝐲) = sum(abs2, 𝐲 .- model(𝐱)) / size(𝐱)[end]
78+
opt = Flux.Optimiser(WeightDecay(1f-4), Flux.ADAM(1f-3))
79+
Flux.@epochs 50 Flux.train!(loss, params(model), data, opt)
80+
```

src/model.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ export
22
FourierNeuralOperator,
33
MarkovNeuralOperator
44

5+
"""
6+
FourierNeuralOperator(;
7+
ch=(2, 64, 64, 64, 64, 64, 128, 1),
8+
modes=(16, ),
9+
σ=gelu
10+
)
11+
12+
Fourier neural operator learns a neural operator with Dirichlet kernel to form a Fourier transformation.
13+
It performs Fourier transformation across infinite-dimensional function spaces and learns better than neural operator.
14+
"""
515
function FourierNeuralOperator(;
616
ch=(2, 64, 64, 64, 64, 64, 128, 1),
717
modes=(16, ),
@@ -19,6 +29,17 @@ function FourierNeuralOperator(;
1929
)
2030
end
2131

32+
"""
33+
MarkovNeuralOperator(;
34+
ch=(1, 64, 64, 64, 64, 64, 1),
35+
modes=(24, 24),
36+
σ=gelu
37+
)
38+
39+
Markov neural operator learns a neural operator with Fourier operators.
40+
With only one time step information of learning, it can predict the following few steps with low loss
41+
by linking the operators into a Markov chain.
42+
"""
2243
function MarkovNeuralOperator(;
2344
ch=(1, 64, 64, 64, 64, 64, 1),
2445
modes=(24, 24),

0 commit comments

Comments
 (0)