|
4 | 4 |
|
5 | 5 | """ |
6 | 6 | FourierNeuralOperator(; |
7 | | - ch=(2, 64, 64, 64, 64, 64, 128, 1), |
8 | | - modes=(16, ), |
9 | | - σ=gelu |
10 | | - ) |
| 7 | + ch = (2, 64, 64, 64, 64, 64, 128, 1), |
| 8 | + modes = (16, ), |
| 9 | + σ = gelu) |
11 | 10 |
|
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. |
| 11 | +Fourier neural operator is a operator learning model that uses Fourier kernel to perform |
| 12 | +spectral convolutions. |
| 13 | +It is a promissing way for surrogate methods, and can be regarded as a physics operator. |
| 14 | +
|
| 15 | +The model is comprised of |
| 16 | +a `Dense` layer to lift (d + 1)-dimensional vector field to n-dimensional vector field, |
| 17 | +and an integral kernel operator which consists of four Fourier kernels, |
| 18 | +and two `Dense` layers to project data back to the scalar field of interest space. |
| 19 | +
|
| 20 | +The role of each channel size described as follow: |
| 21 | +
|
| 22 | +``` |
| 23 | +[1] input channel number |
| 24 | + ↓ Dense |
| 25 | +[2] lifted channel number |
| 26 | + ↓ OperatorKernel |
| 27 | +[3] mapped cahnnel number |
| 28 | + ↓ OperatorKernel |
| 29 | +[4] mapped cahnnel number |
| 30 | + ↓ OperatorKernel |
| 31 | +[5] mapped cahnnel number |
| 32 | + ↓ OperatorKernel |
| 33 | +[6] mapped cahnnel number |
| 34 | + ↓ Dense |
| 35 | +[7] projected channel number |
| 36 | + ↓ Dense |
| 37 | +[8] projected channel number |
| 38 | +``` |
| 39 | +
|
| 40 | +## Keyword Arguments |
| 41 | +
|
| 42 | +* `ch`: A `Tuple` or `Vector` of the 8 channel size. |
| 43 | +* `modes`: The modes to be preserved. A tuple of length `d`, |
| 44 | + where `d` is the dimension of data. |
| 45 | +* `σ`: Activation function for all layers in the model. |
| 46 | +
|
| 47 | +## Example |
| 48 | +
|
| 49 | +```julia |
| 50 | +julia> using NNlib |
| 51 | +
|
| 52 | +julia> FourierNeuralOperator(; |
| 53 | + ch = (2, 64, 64, 64, 64, 64, 128, 1), |
| 54 | + modes = (16,), |
| 55 | + σ = gelu) |
| 56 | +Chain( |
| 57 | + Dense(2 => 64), # 192 parameters |
| 58 | + OperatorKernel( |
| 59 | + Dense(64 => 64), # 4_160 parameters |
| 60 | + OperatorConv(64 => 64, (16,), FourierTransform, permuted=false), # 65_536 parameters |
| 61 | + NNlib.gelu, |
| 62 | + ), |
| 63 | + OperatorKernel( |
| 64 | + Dense(64 => 64), # 4_160 parameters |
| 65 | + OperatorConv(64 => 64, (16,), FourierTransform, permuted=false), # 65_536 parameters |
| 66 | + NNlib.gelu, |
| 67 | + ), |
| 68 | + OperatorKernel( |
| 69 | + Dense(64 => 64), # 4_160 parameters |
| 70 | + OperatorConv(64 => 64, (16,), FourierTransform, permuted=false), # 65_536 parameters |
| 71 | + NNlib.gelu, |
| 72 | + ), |
| 73 | + OperatorKernel( |
| 74 | + Dense(64 => 64), # 4_160 parameters |
| 75 | + OperatorConv(64 => 64, (16,), FourierTransform, permuted=false), # 65_536 parameters |
| 76 | + identity, |
| 77 | + ), |
| 78 | + Dense(64 => 128, gelu), # 8_320 parameters |
| 79 | + Dense(128 => 1), # 129 parameters |
| 80 | +) # Total: 18 arrays, 287_425 parameters, 2.098 MiB. |
| 81 | +``` |
14 | 82 | """ |
15 | 83 | function FourierNeuralOperator(; |
16 | 84 | ch = (2, 64, 64, 64, 64, 64, 128, 1), |
|
29 | 97 |
|
30 | 98 | """ |
31 | 99 | MarkovNeuralOperator(; |
32 | | - ch=(1, 64, 64, 64, 64, 64, 1), |
33 | | - modes=(24, 24), |
34 | | - σ=gelu |
35 | | - ) |
| 100 | + ch = (1, 64, 64, 64, 64, 64, 1), |
| 101 | + modes = (24, 24), |
| 102 | + σ = gelu) |
36 | 103 |
|
37 | 104 | Markov neural operator learns a neural operator with Fourier operators. |
38 | | -With only one time step information of learning, it can predict the following few steps with low loss |
39 | | -by linking the operators into a Markov chain. |
| 105 | +With only one time step information of learning, it can predict the following few steps |
| 106 | +with low loss by linking the operators into a Markov chain. |
| 107 | +
|
| 108 | +The model is comprised of |
| 109 | +a `Dense` layer to lift d-dimensional vector field to n-dimensional vector field, |
| 110 | +and an integral kernel operator which consists of four Fourier kernels, |
| 111 | +and a `Dense` layers to project data back to the scalar field of interest space. |
| 112 | +
|
| 113 | +The role of each channel size described as follow: |
| 114 | +
|
| 115 | +``` |
| 116 | +[1] input channel number |
| 117 | + ↓ Dense |
| 118 | +[2] lifted channel number |
| 119 | + ↓ OperatorKernel |
| 120 | +[3] mapped cahnnel number |
| 121 | + ↓ OperatorKernel |
| 122 | +[4] mapped cahnnel number |
| 123 | + ↓ OperatorKernel |
| 124 | +[5] mapped cahnnel number |
| 125 | + ↓ OperatorKernel |
| 126 | +[6] mapped cahnnel number |
| 127 | + ↓ Dense |
| 128 | +[7] projected channel number |
| 129 | +``` |
| 130 | +
|
| 131 | +## Keyword Arguments |
| 132 | +
|
| 133 | +* `ch`: A `Tuple` or `Vector` of the 7 channel size. |
| 134 | +* `modes`: The modes to be preserved. A tuple of length `d`, |
| 135 | + where `d` is the dimension of data. |
| 136 | +* `σ`: Activation function for all layers in the model. |
| 137 | +
|
| 138 | +## Example |
| 139 | +
|
| 140 | +```julia |
| 141 | +julia> using NNlib |
| 142 | +
|
| 143 | +julia> MarkovNeuralOperator(; |
| 144 | + ch = (1, 64, 64, 64, 64, 64, 1), |
| 145 | + modes = (24, 24), |
| 146 | + σ = gelu) |
| 147 | +Chain( |
| 148 | + Dense(1 => 64), # 128 parameters |
| 149 | + OperatorKernel( |
| 150 | + Dense(64 => 64), # 4_160 parameters |
| 151 | + OperatorConv(64 => 64, (24, 24), FourierTransform, permuted=false), # 2_359_296 parameters |
| 152 | + NNlib.gelu, |
| 153 | + ), |
| 154 | + OperatorKernel( |
| 155 | + Dense(64 => 64), # 4_160 parameters |
| 156 | + OperatorConv(64 => 64, (24, 24), FourierTransform, permuted=false), # 2_359_296 parameters |
| 157 | + NNlib.gelu, |
| 158 | + ), |
| 159 | + OperatorKernel( |
| 160 | + Dense(64 => 64), # 4_160 parameters |
| 161 | + OperatorConv(64 => 64, (24, 24), FourierTransform, permuted=false), # 2_359_296 parameters |
| 162 | + NNlib.gelu, |
| 163 | + ), |
| 164 | + OperatorKernel( |
| 165 | + Dense(64 => 64), # 4_160 parameters |
| 166 | + OperatorConv(64 => 64, (24, 24), FourierTransform, permuted=false), # 2_359_296 parameters |
| 167 | + NNlib.gelu, |
| 168 | + ), |
| 169 | + Dense(64 => 1), # 65 parameters |
| 170 | +) # Total: 16 arrays, 9_454_017 parameters, 72.066 MiB. |
| 171 | +
|
| 172 | +``` |
40 | 173 | """ |
41 | 174 | function MarkovNeuralOperator(; |
42 | 175 | ch = (1, 64, 64, 64, 64, 64, 1), |
|
0 commit comments