FNO
Fourier Neural Operator (FNO)¤
neojax.models.fno.FNO
¤
General n-dimensional Fourier Neural Operator (FNO).
The model consists of a lifting layer that maps the input to a higher-dimensional latent space, a sequence of FNO blocks (spectral convolutions + skip connections) optionally interleaved with pointwise MLPs, and a final projection layer.
The implementation is as in the references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyArray
|
PRNG key for parameter initialization. |
required |
in_channels
|
int
|
Number of input channels (e.g., coordinates + initial conditions). |
required |
out_channels
|
int
|
Number of output channels (e.g., solution field). |
required |
hidden_channels
|
int
|
Hidden channel dimension (latent width)
used throughout the FNO blocks. This significantly affects
the number of parameters. Good starting point is 64 and
increase if needed. Update |
required |
n_layers
|
int
|
Number of consecutive FNO blocks. |
required |
modes
|
Sequence[int]
|
Number of Fourier modes to retain across each spatial dimension. |
required |
activation
|
Callable
|
Activation function used within the layers.
Defaults to |
gelu
|
use_channel_mlp
|
bool
|
Whether to apply a pointwise channel MLP
after each FNO block. Defaults to |
True
|
local_operator
|
Optional[Literal['linear', 'soft-gating', 'identity']]
|
Type of skip connection inside FNO blocks.
Can be |
'linear'
|
use_local_operator_bias
|
bool
|
Whether to use a bias term
in the FNO blocks local operator. Default is |
False
|
channel_mlp_residual
|
Optional[Literal['linear', 'soft-gating', 'identity']]
|
Type of skip connection around channel MLPs.
Can be |
'soft-gating'
|
channel_mlp_expansion
|
float | None
|
Expansion factor for hidden dimension in the channel MLPs. Defaults to 0.5. |
0.5
|
channel_mlp_activations
|
Callable | Sequence[Callable]
|
Activation function or sequence
of activation functions used inside the channel MLPs.
Default is |
gelu
|
channel_mlp_dropout
|
float
|
Dropout probability applied after each layer (except the last) of the channel MLPs. Defaults to 0.0. |
0.0
|
normalization
|
Optional[Literal['layer', 'instance', 'group']]
|
Type of normalization to use in FNO blocks.
Can be |
'layer'
|
norm_groups
|
int
|
Number of groups for group normalization. Default is 1. |
1
|
use_fno_residual
|
bool
|
Whether to use residual connection around FNO blocks. Default is True. |
True
|
preactivation
|
bool
|
Whether to use pre-activation style blocks. Default is False. |
False
|
n_lift_layers
|
int
|
Number of layers in the lifting MLP. Defaults to 2. |
2
|
n_proj_layers
|
int
|
Number of layers in the projection MLP. Defaults to 2. |
2
|
lift_channel_ratio
|
float
|
Ratio of lifting channels to hidden_channels. The number of lifting channels in the lifting block of the FNO is lifting_channel_ratio * hidden_channels (e.g. default 2 * hidden_channels). |
2.0
|
proj_channel_ratio
|
float
|
Ratio of projection channels to hidden_channels. The number of projection channels in the projection block of the FNO is projection_channel_ratio * hidden_channels (e.g. default 2 * hidden_channels). |
2.0
|
positional_embedding
|
Union[GridEmbeddingNd, Literal['grid'], NoneType]
|
Positional embedding to apply
to last channels of raw input before passing through UNO.
Default is "grid", a regular |
None
|
domain_padding
|
float | Sequence[float] | None
|
Percentage of padding to use between, e.g. 0.1 is 10% padding. If single float, this padding is used for all dims. Sequence of floats indicates padding percentage per dim. Default is None, no padding. |
None
|
enforce_hermitian_symmetry
|
bool
|
Whether to enforce
hermitian symmetry on the outputs of the spectral convolutions
before calling |
True
|
fft_norm
|
Optional[Literal['forward', 'backward', 'ortho']]
|
FFT normalization. Can be |
'forward'
|
is_complex_data
|
bool
|
Whether input data is complex valued. If True, uses full FFT. Default is False. |
False
|
resolution_scaling_factor
|
float | int | Sequence[float | int] | None
|
Layerwise factor by which to scale the domain resolution of the function. Default is None. Passing a scalar scales the resolution by that value each layer. Passing a sequence, scales the i-th layer by the i-th value. |
None
|
ranks
|
int | Sequence[int] | None
|
Number of ranks to contract the spectral tensors to.
If |
None
|
init_std
|
Union[float, Literal['auto']]
|
Standard deviation to use for weight initialization, by default 'auto'. If 'auto', uses (2 / (in_channels * out_channels)) ** 0.5. |
'auto'
|
factorization
|
Union[BaseTensor, Literal['tucker', 'cp', 'tt'], NoneType]
|
Tensor factorization type. Can be a |
None
|
implementation
|
Literal['reconstructed', 'factorized']
|
Weight reconstruction mode. Can be "reconstructed" or "factorized". Default is "factorized". |
'factorized'
|
separable
|
bool
|
Whether to use separable implementation of contraction. If True, contracts factors of factorized tensor weight individually. Default is False. |
False
|
Internal Attributes
These fields store the internal layers state (and weights).
- positional_embedding (
GridEmbeddingNd | None): Positional embedding to apply to last channels of raw input before passing through FNO. - lifting (
PointwiseMLP): ThePointwiseMLPused to lift inputs to the hiddenhidden_channels. - fno_blocks (
FNOBlocks): TheFNOBlockssequence containing spectral convolutions. - projection (
PointwiseMLP): ThePointwiseMLPused to project latent features toout_channels. - padding (
DomainPadding | None): Percentage of domain padding to use.
Cite
Fourier Neural Operator for Parametric Partial Differential Equations
@inproceedings{
li2021fourier,
title={Fourier Neural Operator for
Parametric Partial Differential Equations},
author={Zongyi Li and Nikola Kovachki and
Kamyar Azizzadenesheli and Burigede liu and
Kaushik Bhattacharya and Andrew Stuart and Anima Anandkumar},
booktitle={International Conference on Learning Representations},
year={2021},
url={https://openreview.net/forum?id=c8P9NQVtmnO}
}
Neural Operator: Learning Maps Between Function Spaces With Applications to PDEs
@article{kovachki2023neural,
title={Neural operator: Learning maps between
function spaces with applications to pdes},
author={Kovachki, Nikola and Li, Zongyi and Liu,
Burigede and Azizzadenesheli, Kamyar and Bhattacharya,
Kaushik and Stuart, Andrew and Anandkumar, Anima},
journal={Journal of Machine Learning Research},
volume={24},
number={89},
pages={1--97},
year={2023}
}
__call__(x: Inexact[Array, 'in_c ...'], *, key: PRNGKeyArray | None = None, inference: bool = False) -> Inexact[Array, 'out_c ...']
¤
Forward pass of the FNO model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Inexact[Array, 'in_c ...']
|
Input array of shape |
required |
key
|
PRNGKeyArray | None
|
PRNG key used for dropout masks in FNO blocks. |
None
|
inference
|
bool
|
If True, dropout is disabled. |
False
|
Returns:
| Type | Description |
|---|---|
Inexact[Array, 'out_c ...']
|
The predicted field of shape |