DeepONet is a deep neural network for operator learning proposed by a research team affiliated with Brown University and published in Nature Machine Intelligence in 2021. Unlike conventional neural networks, which primarily learn mappings between finite-dimensional vectors, DeepONet learns nonlinear operator mappings directly between function spaces, establishing a relationship between an input function and its corresponding output function. It can approximate solution operators defined by ordinary differential equations, partial differential equations, and other physical systems, providing an efficient data-driven modeling approach for complex dynamical systems and scientific computing.
Using the OneScience skill workflow, this project independently reproduces experiments related to the DeepONet paper.
DeepONet uses a dual-network architecture consisting of a Branch Net and a Trunk Net. The Branch Net encodes discrete samples of an input function at fixed sensor locations, while the Trunk Net encodes the spatial or spatiotemporal coordinates at which predictions are requested. The output of the target operator at a specified location is obtained from the inner product of the two feature vectors plus a bias term.
Use Cases
Use case
Description
Operator learning
Learns mappings between function spaces, directly predicting an output function (G(u)) from an input function (u). This is useful for function-to-function mappings that conventional neural networks cannot easily handle.
Spatiotemporal field prediction
Provides fast surrogate predictions for fluid problems such as Navier–Stokes and compressible Euler equations.
Multiscale physical-field modeling
The Trunk Net can directly accept multidimensional coordinates such as ((x,t)), making it suitable for predicting temperature, concentration, diffusion, and other fields that vary in space and time.
Multiple query-point prediction
For a fixed input function, solutions at different spatial or temporal locations can be predicted by changing only the query coordinates supplied to the Trunk Net.
Usage
1. Using OneCode
Try intelligent, one-click AI4S programming in the OneCode online environment:
1# Activate DTK and Conda first2conda create -n onescience311 python=3.11 -y
3conda activate onescience311
4# Installation with uv is also supported5pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
GPU environment
bash
1# Activate Conda first2conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=123conda activate onescience311
4# Installation with uv is also supported5pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
Training Data
This project does not depend on an external dataset. The E3 data is generated on the fly by models/dataset.py according to config/config.yaml and corresponds to the following parameterized one-dimensional PDE:
Reference solutions are first generated on 200 spatial grid points and then downsampled to 100 points. The nonlinear flux is discretized using a fifth-order WENO scheme, and time integration uses a fourth-order Runge–Kutta method. Each trajectory contains 250 time points and has shape:
$$
u\in\mathbb R^{250\times100}.
$$
The model uses a history window of length $K=25$ to predict the next 25 time steps. One supervised sample can be written as:
The default configuration reproduces four operator-learning experiments from the DeepONet paper: antiderivative, nonlinear ODE, forced pendulum, and diffusion–reaction equation. By default, the training script runs the antiderivative experiment, with input functions and reference solutions generated on the fly by models/dataset.py.
Set --experiment to all to run all four main experiments from the paper sequentially.
During training, the training loss, test MSE, and relative L2 error are printed at the intervals configured in config/config.yaml. When the test MSE improves, the model weights, optimizer state, current iteration, evaluation metrics, and effective runtime configuration are saved to weight/best_model.pth.
Trained Weights
weight/best_model.pth contains the best weights from the full antiderivative experiment and can be used directly for inference or fine-tuning.
Inference
Before running inference, make sure the configured data path is valid and weight/best_model.pth exists.
pde_grid: two-dimensional spatiotemporal field for the diffusion–reaction equation.
The default batch size is 8,192 and can be changed with --batch-size. Predictions and evaluation metrics are saved to the results directory.
Evaluation and Visualization
After training and inference, summarize existing experiment results and generate training curves, prediction comparisons, and an evaluation report with:
This project is an independent reproduction of the DeepONet paper. The official implementation is licensed under the MIT License. The project code, model weights, training data, and third-party dependencies remain subject to their respective license terms.