mindflow.cell.FNO3D
- class mindflow.cell.FNO3D(in_channels, out_channels, n_modes, resolutions, hidden_channels=20, lifting_channels=None, projection_channels=128, n_layers=4, data_format='channels_last', fnoblock_act='gelu', mlp_act='gelu', add_residual=False, positional_embedding=True, dft_compute_dtype=mstype.float32, fno_compute_dtype=mstype.float16)[source]
The 3D Fourier Neural Operator, which usually contains a Lifting Layer, a Fourier Block Layer and a Projection Layer. The details can be found in Zongyi Li, et. al: FOURIER NEURAL OPERATOR FOR PARAMETRIC PARTIAL DIFFERENTIAL EQUATIONS.
- Parameters
in_channels (int) – The number of channels in the input space.
out_channels (int) – The number of channels in the output space.
n_modes (Union[int, list(int)]) – The number of modes reserved after linear transformation in Fourier Layer.
resolutions (Union[int, list(int)]) – The resolutions of the input tensor.
hidden_channels (int) – The number of channels of the FNOBlock input and output. Default:
20
.lifting_channels (int) – The number of channels of the lifting layer mid channels. Default: None.
projection_channels (int) – The number of channels of the projection layer mid channels. Default:
128
.n_layers (int) – The number that Fourier Layer nests. Default:
4
.data_format (str) – The input data channel sequence. Default:
channels_last
. Support value:"channels_last"
,"channels_first"
.fnoblock_act (Union[str, class]) – The activation function for FNOBlock, could be either str or class. Default:
"gelu"
.mlp_act (Union[str, class]) – The activation function for MLP layers, could be either str or class. Default:
gelu
.add_residual (bool) – Whether to add residual in FNOBlock or not. Default:
False
.positional_embedding (bool) – Whether to embed positional information or not. Default:
True
.dft_compute_dtype (dtype.Number) – The computation type of DFT in SpectralConvDft. Default:
mstype.float32
.fno_compute_dtype (dtype.Number) – The computation type of MLP in fno skip. Default:
mstype.float16
. Should bemstype.float32
ormstype.float16
. mstype.float32 is recommended for the GPU backend, mstype.float16 is recommended for the Ascend backend.
- Inputs:
x (Tensor) - Tensor of shape \((batch\_size, resolution[0], resolution[1], resolution[2], \ in\_channels)\).
- Outputs:
Tensor, the output of this FNOBlocks.
output (Tensor) -Tensor of shape \((batch\_size, resolution[0], resolution[1], resolution[2], out\_channels)\).
- Raises
TypeError – If in_channels is not an int.
TypeError – If out_channels is not an int.
TypeError – If hidden_channels is not an int.
TypeError – If lifting_channels is not an int.
TypeError – If projection_channels is not an int.
TypeError – If n_layers is not an int.
TypeError – If data_format is not a str.
TypeError – If add_residual is not an bool.
TypeError – If positional_embedding is not an bool.
- Supported Platforms:
Ascend
GPU
Examples
>>> import numpy as np >>> import mindspore >>> import mindflow >>> from mindspore import Tensor >>> import mindspore.common.dtype as mstype >>> from mindflow.cell import FNO3D >>> data = Tensor(np.ones([2, 128, 128, 128, 3]), mstype.float32) >>> net = FNO3D(in_channels=3, out_channels=3, n_modes=[20, 20, 20], resolutions=[128, 128, 128]) >>> out = net(data) >>> print(data.shape, out.shape) (2, 128, 128, 128, 3) (2, 128, 128, 128, 3)