FourierNeuralOperator<T>
Models & Types · AiDotNet.PhysicsInformed.NeuralOperators
Implements the Fourier Neural Operator (FNO) for learning operators between function spaces.
Inheritance: NeuralNetworkBase<T> → FourierNeuralOperator<T>
How It Works
For Beginners: A Neural Operator learns mappings between entire functions, not just inputs to outputs.
Traditional Neural Networks:
- Learn: point → point mappings
- Input: a vector (x, y, z)
- Output: a vector (u, v, w)
- Example: (temperature, pressure) → (velocity)
Neural Operators:
- Learn: function → function mappings
- Input: an entire function a(x)
- Output: an entire function u(x)
- Example: initial condition → solution after time T
Why This Matters: Many problems in physics involve operators:
- PDE solution operator: (initial/boundary conditions) → (solution)
- Green’s function: (source) → (response)
- Transfer function: (input signal) → (output signal)
Traditionally, you’d need to solve the PDE from scratch for each new set of conditions. With neural operators, you train once, then can instantly evaluate for new conditions!
Fourier Neural Operator (FNO): The key innovation is doing computations in Fourier space.
How FNO Works:
- Lift: Embed input function into higher-dimensional space
- Fourier Layers (repeated):
a) Apply FFT to transform to frequency domain b) Linear transformation in frequency space (learn weights) c) Apply inverse FFT to return to physical space d) Add skip connection and activation
- Project: Map back to output function
Why Fourier Space?
- Many PDEs have simple form in frequency domain
- Derivatives → multiplication (∂/∂x in physical space = ik in Fourier space)
- Captures global information efficiently
- Natural for periodic problems
- Computational efficiency (FFT is O(n log n))
Key Advantages:
- Resolution-invariant: Train at one resolution, evaluate at another
- Fast: Instant evaluation after training (vs. solving PDE each time)
- Mesh-free: No discretization needed
- Generalizes well: Works for different parameter values
- Captures long-range dependencies naturally
Applications:
- Fluid dynamics (Navier-Stokes)
- Climate modeling (weather prediction)
- Material science (stress-strain)
- Seismic imaging
- Quantum chemistry (electron density)
Example Use Case: Problem: Solve 2D Navier-Stokes for different initial vorticity fields Traditional: Solve PDE numerically for each initial condition (slow) FNO: Train once on many examples, then instantly predict solution for new initial conditions
Historical Context: FNO was introduced by Li et al. in 2021 and has achieved remarkable success in learning solution operators for PDEs, often matching or exceeding traditional numerical methods in accuracy while being orders of magnitude faster.
Example
// Each row is one sampled function: the operator learns a mapping between whole
// functions, not between individual points.
var inputFunctions = Tensor<float>.CreateRandom(8, 64);
var outputFunctions = Tensor<float>.CreateRandom(8, 64);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
.ConfigureModel(new FourierNeuralOperator<float>())
.Build(inputFunctions, outputFunctions);
var newInputFunction = Tensor<float>.CreateRandom(1, 64);
Tensor<float> prediction = result.Predict(newInputFunction);
Constructors
| Constructor | Summary |
|---|---|
FourierNeuralOperator() |
Initializes a new instance of the Fourier Neural Operator with default configuration. |
FourierNeuralOperator(NeuralNetworkArchitecture<T> architecture, int[] spatialDimensions, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, FourierNeuralOperatorOptions options) |
Initializes a new instance of the Fourier Neural Operator. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
Serializes FNO-specific data. |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
Gets metadata about the FNO model. |
Tensor<T> Forward(Tensor<T> input) |
Forward pass through the FNO. |
Tensor<T> ForwardForTraining(Tensor<T> input) |
Forward pass used by tape-based training. |
Tensor<T> ForwardWithMemory(Tensor<T> input) |
|
TrainingHistory<T> Train(Tensor<T>[] inputFunctions, Tensor<T>[] outputFunctions, int epochs, double learningRate) |
Trains the FNO on input-output function pairs. |
Vector<T> GetGradients() |