DeepONet¶
# linux
wget -c https://paddle-org.bj.bcebos.com/paddlescience/datasets/DeepONet/antiderivative_unaligned_train.npz
wget -c https://paddle-org.bj.bcebos.com/paddlescience/datasets/DeepONet/antiderivative_unaligned_test.npz
# windows
# curl https://paddle-org.bj.bcebos.com/paddlescience/datasets/deeponet/antiderivative_unaligned_train.npz -o antiderivative_unaligned_train.npz
# curl https://paddle-org.bj.bcebos.com/paddlescience/datasets/deeponet/antiderivative_unaligned_test.npz -o antiderivative_unaligned_test.npz
python deeponet.py
# linux
wget -c https://paddle-org.bj.bcebos.com/paddlescience/datasets/DeepONet/antiderivative_unaligned_train.npz
wget -c https://paddle-org.bj.bcebos.com/paddlescience/datasets/DeepONet/antiderivative_unaligned_test.npz
# windows
# curl https://paddle-org.bj.bcebos.com/paddlescience/datasets/deeponet/antiderivative_unaligned_train.npz -o antiderivative_unaligned_train.npz
# curl https://paddle-org.bj.bcebos.com/paddlescience/datasets/deeponet/antiderivative_unaligned_test.npz -o antiderivative_unaligned_test.npz
python deeponet.py mode=eval EVAL.pretrained_model_path=https://paddle-org.bj.bcebos.com/paddlescience/models/deeponet/deeponet_pretrained.pdparams
| Pretrained Model | Metrics |
|---|---|
| deeponet_pretrained.pdparams | loss(G_eval): 0.00003 L2Rel.G(G_eval): 0.01799 |
1. Background Introduction¶
Based on the universal approximation theorem for operators, neural networks can approximate not just functions, but also nonlinear operators that map one function space to another. This is the core concept of "operator learning."
DeepONet, a prominent operator learning framework, demonstrates significant potential across diverse fields:
- Fluid Dynamics: Solving partial differential equations (PDEs) like the Navier-Stokes equations for aerodynamics and climate modeling.
- Computer Vision: Learning complex mappings for image classification, segmentation, and medical analysis.
- Signal Processing: Applications in denoising, compression, and restoration for communications and radar.
- Control Systems: Modeling system dynamics for predictive control and optimization.
- Finance & Environment: Risk assessment, market forecasting, and climate prediction.
While DeepONet is versatile, successful application requires domain-specific adaptation and optimization.
2. Problem Definition¶
Consider the following Ordinary Differential Equation (ODE) system:
Here, \(u \in V\) (continuous on \([a, b]\)) is the input signal, and the solution \(\mathbf{s}: [a,b] \rightarrow \mathbb{R}^K\) is the output. We define an operator \(G\) such that \(\mathbf{s}(x) = (G u)(x)\). This can be expressed in integral form:
Our goal is to train a neural network that takes the function \(u\) and a coordinate \(x\) as inputs and predicts the value \((G u)(x)\). Essentially, we aim to learn the operator \(G\).
Note: In this specific example, \(G\) acts as an integral operator (antiderivative) with the initial condition \((G u)(0)=0\).
3. Problem Solving¶
Next, we will explain how to convert the problem into PaddleScience code step by step and solve the problem using deep learning methods. In order to quickly understand PaddleScience, only key steps such as model construction, equation construction, and computational domain construction are described below, while other details please refer to API Documentation.
3.1 Dataset Introduction¶
This case dataset uses the dataset provided by the DeepXDE official documentation. One npz file already contains the training set and validation set. Download Address
The data file description is as follows:
antiderivative_unaligned_train.npz
| Field Name | Description |
|---|---|
| X_train0 | Training input data corresponding to \(u\), shape is (10000, 100) |
| X_train1 | Training input data corresponding to \(y\), shape is (10000, 1) |
| y_train | Training label data corresponding to \(G(u)\), shape is (10000,1) |
antiderivative_unaligned_test.npz
| Field Name | Description |
|---|---|
| X_test0 | Test input data corresponding to \(u\), shape is (100000, 100) |
| X_test1 | Test input data corresponding to \(y\), shape is (100000, 1) |
| y_test | Test label data corresponding to \(G(u)\), shape is (100000,1) |
3.2 Model Construction¶
The inputs are the function \(u\) and the coordinate \(y\), and the output is the value \(G(u)(y)\). Following the DeepONet architecture, we employ a Branch Net (for \(u\)) and a Trunk Net (for \(y\)).
We specify input keys as u and y, and the output key as G. The DeepONet model is instantiated by configuring the number of sensors, feature channels, hidden layers, neurons, and activation functions.
3.3 Constraint Construction¶
We use supervised learning to train the model. First, we configure the data loader, specifying file paths, input/label keys, and aliases.
3.3.1 Supervised Constraint¶
Since we train in a supervised manner, supervised constraint SupervisedConstraint is used here:
- Dataloader: Uses
train_dataloader_cfg. - Loss: MSE with
reduction="mean". - Target: The model output
G.
The constraint is then stored in a dictionary.
3.4 Hyperparameter Setting¶
We set the training epochs to 10,000 and the evaluation interval to 500 epochs.
3.5 Optimizer Construction¶
We use the Adam optimizer with a learning rate of 0.001.
3.6 Validator Construction¶
To monitor performance, we construct a SupervisedValidator for periodic evaluation on the test set.
For evaluation metric metric, select ppsci.metric.L2Rel.
Other configurations are similar to the settings of Constraint Construction.
3.7 Model Training and Evaluation¶
With all components configured, we pass them to ppsci.solver.Solver to commence training and evaluation.
3.8 Result Visualization¶
Post-training, we verify the model by constructing 9 synthetic \(u-G(u)\) function pairs. We discretize \(u\) and \(y\), predict \(G(u)(y)\), and compare the results with the analytical solutions.
4. Complete Code¶
| deeponet.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |








