DeepONet for neural operator learning

Solving a PDE means mapping one function to another, for example an initial condition to the solution over time. Instead of a map between finite-dimensional vectors, DeepONet learns such an operator: a map from an input function to an output function. I implemented it in Julia and tested it on an integration operator and two PDEs.

There’s one difference from the original architecture, though: I added a few dense layers after the branch and trunk outputs are combined, to give the model more capacity.

Neural operator learning

Operator learning approximates mappings between function spaces, which are infinite-dimensional. This is the natural setting for PDEs, where both the input (an initial condition, a coefficient field) and the output (the solution) are functions.

Universal approximation theorem for operators

From the DeepONet paper:

… \(G\) is a nonlinear continuous operator. Then for any \(\epsilon>0\), there exist parameters such that the following holds for all \(u\) and \(y\):

\[ \left|G(u)(y) - \sum_{k=1}^p \underbrace{\sum_{i=1}^n c_i^k \sigma\left(\sum_{j=1}^m \xi_{ij}^ku(x_j)+\theta_i^k\right)}_\text{branch} \underbrace{\sigma(w_k \cdot y+\zeta_k)}_\text{trunk} \right|<\epsilon \]

DeepONet architecture

DeepONet has two subnetworks:

Their outputs are combined to approximate the target operator.

Installation

The package can be installed from GitHub:

pkg> add https://github.com/chutommy/DeepONet.jl

Usage

A minimal training setup. The full examples below include the data loaders and model settings.

model = DeepONetModel( M, 2, 20, activations;
    branch_sizes = branch_sizes,
    trunk_sizes = trunk_sizes,
    output_sizes = output_sizes,
)

opt_state = Flux.setup(Flux.AdamW(0.0003), model)
train!(model, opt_state, train_loader, test_loader)

Examples

Integration on \([0, 1]\)

The first example learns the integration operator on \([0, 1]\), which maps a function to its antiderivative:

\[ F(x) = \int_0^x f(t) \, dt \]

The predictions are compared against the exact integrals.

Code: examples/integrals.jl.

Burgers’ equation

The 1D Burgers’ equation:

\[ \frac{\partial u}{\partial t} + u \frac{\partial u}{\partial x} = \nu \frac{\partial^2 u}{\partial x^2} \]

The model maps an initial condition to the solution over time.

Code: examples/burgers.jl.

Darcy flow

Darcy’s law for flow through porous media:

\[ \mathbf{v} = -\frac{\kappa}{\mu} \nabla p \]

Combined with conservation of mass, this gives an equation for the pressure, \(-\nabla \cdot (\kappa \nabla p) = f\). The input is the permeability field \(\kappa\), here a medium made of two materials, and the network predicts the pressure field \(p\).

Code: examples/darcys.jl.

Conclusion

DeepONet learned all three operators from sampled input-output pairs. It gets the overall shape of the solutions right but smooths out fine detail: the predicted integrals follow the trend without the small wiggles, and the Darcy predictions blur the sharp edges between the two materials. The model is trained once and then can evaluate a new input in a single forward pass instead of running a numerical solver.