Skip to content

Neural operators: DeepONet and the Fourier neural operator

A PINN solves one problem. A neural operator learns the map from a whole input function to its solution, so one trained network serves a family of problems. Build a DeepONet prediction and one Fourier layer by hand.

Advanced ~15 min9 steps

What runs in CodeSplash

You will be able to

  • Say what an operator maps and how it differs from fitting one solution
  • Compute a DeepONet prediction as a branch–trunk dot product
  • Explain one Fourier layer: transform, keep low modes, mix, transform back
  • Name the limits of sensors, grids and training distributions

Read first

01

From one solution to a solution map

Read

A PINN learns one solution u(x)u(x) for one set of conditions. Change the forcing and you train again. A neural operatorNeural operatorA network that maps a whole input function (a forcing, a field) to an output function, trained on many solved examples. learns the map G\mathcal{G} from an input function (a forcing, an initial field, a coefficient map) to the output function:

Gθ:u↦Gθ(u)(y).\mathcal{G}_\theta : u \mapsto \mathcal{G}_\theta(u)(y).

It is trained on many solved pairs, often from a numerical solver, and then predicts new cases fast. It is a surrogate for the solver, so it is only as good as the family of inputs it saw.

02

DeepONet: branch and trunk

Read

DeepONetDeepONetA neural operator that encodes the input function at fixed sensors (branch) and the query location (trunk), then takes their dot product. samples the input function at mm fixed sensors. A branch network maps those values to pp coefficients; a trunk network maps the query location yy to pp basis values. The prediction is their dot product:

Gθ(u)(y)=∑k=1pbk(u(x1),…,u(xm)) tk(y)+b0.\mathcal{G}_\theta(u)(y) = \sum_{k=1}^{p} b_k\big(u(x_1), \dots, u(x_m)\big)\, t_k(y) + b_0 .

The reference samples sin⁡(πx)\sin(\pi x) at 5 sensors and uses a 3-term trunk. At six query points from 0 to 1 it predicts 0.620, 1.196, 1.605, 1.743, 1.609 and 1.308: one curve from one forward pass.

Reference · SPE014 · Needs a data type CodeSplash doesn't load yetDeepONetDeepONet learns a mapping between functions, such as an input forcing field and a solution field, rather than a single fixed-input solution.
03

A DeepONet prediction by hand

Explore
Python
import numpy as np
sensors = np.linspace(0, 1, 5); u_at_sensors = np.sin(np.pi * sensors)
W = np.arange(15.).reshape(5, 3) / 20
branch = np.tanh(u_at_sensors @ W)                                   # p = 3 coefficients
y = np.linspace(0, 1, 6)
trunk = np.column_stack([np.ones_like(y), y, np.sin(np.pi * y)])     # 3 basis values per query
print(trunk @ branch)
R
sensors <- seq(0, 1, length.out = 5); u_at_sensors <- sin(pi * sensors)
W <- matrix(0:14, 5, 3, byrow = TRUE) / 20
branch <- tanh(drop(u_at_sensors %*% W))                             # p = 3 coefficients
y <- seq(0, 1, length.out = 6)
trunk <- cbind(1, y, sin(pi * y))                                    # 3 basis values per query
print(drop(trunk %*% branch))

A different input function changes only the branch coefficients; the trunk's basis stays the same. If two inputs agree at every sensor but differ between them, DeepONet can't tell them apart.

04

The Fourier neural operator

Read

The Fourier neural operatorFourier neural operatorA neural operator whose layers mix a field's lowest Fourier modes with learned weights, plus a pointwise path, on a regular grid. works on fields sampled on a grid. Each layer has two paths: a pointwise linear map WW, and a spectral path that takes the Fourier transform, multiplies the lowest modes by learned weights R(k)R(k), drops the rest and transforms back:

vl+1(x)=σ(Wvl(x)+F−1[R(k) F(vl)(k)](x)).v_{l+1}(x) = \sigma\Big(W v_l(x) + \mathcal{F}^{-1}\big[R(k)\, \mathcal{F}(v_l)(k)\big](x)\Big).

The spectral path mixes information across the whole grid in one step. Keeping few modes smooths away fine detail.

Reference · SPE015 · Needs a data type CodeSplash doesn't load yetFourier Neural Operator (FNO)FNO learns operators between discretized fields using spectral convolutions, enabling reusable surrogates across families of PDE inputs.
05

One Fourier layer

Explore

The reference builds a 16-point signal from one low and one higher frequency, keeps the first three Fourier modes with fixed weights, adds a small pointwise path and applies tanh. The first outputs are 0.030, 0.342, 0.548, 0.666 and 0.716. The higher frequency sits above the kept modes, so the spectral path removes it.

Python
import numpy as np
n = 16; g = np.arange(n) / n
x = np.sin(2 * np.pi * g) + .3 * np.cos(6 * np.pi * g)
spec = np.fft.rfft(x); keep = np.zeros_like(spec); keep[:3] = [1., .8, .4]
spectral = np.fft.irfft(keep * spec, n=n)                 # low modes only
print(np.tanh(.1 * x + spectral)[:5])                     # pointwise path + spectral path
R
n <- 16; g <- (0:(n - 1)) / n
x <- sin(2 * pi * g) + .3 * cos(6 * pi * g)
spec <- fft(x); keep <- complex(n); keep[1:3] <- c(1, .8, .4); keep[(n - 1):n] <- c(.4, .8)  # mirror for a real result
spectral <- Re(fft(keep * spec, inverse = TRUE)) / n      # low modes only
print(tanh(.1 * x + spectral)[1:5])                       # pointwise path + spectral path
06

Where operators break

Predict

Predict first

An operator was trained on smooth forcings. You give it a forcing with a sharp jump. What should you expect?

It predicts as well as on training-like inputsIt may fail: the input is outside the training family
Reveal

It may fail. Operators interpolate within the family of inputs they saw. Sharp features, new boundary shapes or new grids are a shift. Check errors on inputs like the ones you will use, against a solver.

07

What runs here

Read
08

Check: neural operators

Checkpoint

Check yourself

What does a neural operator learn that a PINN doesn't?

Show the answer

Answer: b

A PINN fits one solution; an operator is trained across a family of problems.

Check yourself

In DeepONet, what does the trunk network take as input?

Show the answer

Answer: b

The branch reads the input function at sensors; the trunk reads the query location. Their dot product is the prediction there.

Check yourself

Two input functions match at every sensor but differ between sensors. What does DeepONet predict for them?

Show the answer

Answer: a

Sensor placement decides which inputs the network can distinguish.

Check yourself

What happens to fine detail when an FNO layer keeps only a few Fourier modes?

Show the answer

Answer: b

Truncating modes smooths the spectral path. More modes keep finer structure at the cost of parameters.

Check yourself

Why can one FNO layer connect points that are far apart on the grid?

Show the answer

Answer: a

The spectral path is a global convolution done cheaply in Fourier space. Its FFT also assumes the grid wraps around, which may not suit every boundary.

Check yourself

How should you validate a trained operator before using it in place of a solver?

Show the answer

Answer: b

Operators are surrogates. Their errors on the inputs you care about, against a trusted solver, are the evidence.

09

Recap

Recap
  • Neural operators learn maps between functions, trained on many solved pairs.
  • DeepONet: branch over sensor values, trunk over the query location, dot product.
  • FNO: a pointwise path plus a spectral path on a few low modes.
  • They interpolate within their training family. Both need function data CodeSplash doesn't load yet.

Concepts in this lesson