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.
What runs in CodeSplash
- SPE014DeepONet Needs a data type CodeSplash doesn't load yet
- SPE015Fourier Neural Operator (FNO) Needs a data type CodeSplash doesn't load yet
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
From one solution to a solution map
ReadA PINN learns one solution 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 from an input function (a forcing, an initial field, a coefficient map) to the output function:
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.
DeepONet: branch and trunk
ReadDeepONetDeepONetA 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 fixed sensors. A branch network maps those values to coefficients; a trunk network maps the query location to basis values. The prediction is their dot product:
The reference samples 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.A DeepONet prediction by hand
Exploreimport 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)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.
The Fourier neural operator
ReadThe 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 , and a spectral path that takes the Fourier transform, multiplies the lowest modes by learned weights , drops the rest and transforms back:
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.One Fourier layer
ExploreThe 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.
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 pathn <- 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 pathWhere operators break
PredictPredict first
An operator was trained on smooth forcings. You give it a forcing with a sharp jump. What should you expect?
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.
What runs here
ReadCheck: neural operators
CheckpointCheck 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.
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