mindscience.models.neural_operator.FFNO2D
- class mindscience.models.neural_operator.FFNO2D(in_channels, out_channels, n_modes, resolutions, hidden_channels=20, lifting_channels=None, projection_channels=128, factor=1, n_layers=4, n_ff_layers=2, ff_weight_norm=False, layer_norm=True, share_weight=False, r_padding=0, data_format='channels_last', positional_embedding=True, dft_compute_dtype=mstype.float32, ffno_compute_dtype=mstype.float16)[source]
The 2D Factorized Fourier Neural Operator, which usually contains a Lifting Layer, a Factorized Fourier Block Layer and a Projection Layer. The details can be found in A. Tran, A. Mathews, et. al: FACTORIZED FOURIER NEURAL OPERATORS.
- 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, optional) – The number of channels of the FNOBlock input and output. Default:
20.lifting_channels (int, optional) – The number of channels of the lifting layer mid channels. Default:
None.projection_channels (int, optional) – The number of channels of the projection layer mid channels. Default:
128.factor (int, optional) – The number of neurons in the hidden layer of a feedforward network. Default:
1.n_layers (int, optional) – The number that Fourier Layer nests. Default:
4.n_ff_layers (int, optional) – The number of layers (hidden layers) in the feedforward neural network. Default:
2.ff_weight_norm (bool, optional) – Whether to do weight normalization in feedforward or not. Used as a reserved function interface, the weight normalization is not supported in feedforward. Default:
False.layer_norm (bool, optional) – Whether to do layer normalization in feedforward or not. Default:
True.share_weight (bool, optional) – Whether to share weights between SpectralConv layers or not. Default:
False.r_padding (int, optional) – The number used to pad a tensor on the right in a certain dimension. Default:
0.data_format (str, optional) – The input data channel sequence. Default:
"channels_last".positional_embedding (bool, optional) – Whether to embed positional information or not. Default:
True.dft_compute_dtype (dtype.Number, optional) – The computation type of DFT in SpectralConvDft. Default:
mstype.float32.ffno_compute_dtype (dtype.Number, optional) – The computation type of MLP in fno skip. Should be
mstype.float32ormstype.float16.mstype.float32is recommended for the GPU backend,mstype.float16is recommended for the Ascend backend. Default:mstype.float16.
- Inputs:
x (Tensor) - Tensor of shape \((batch\_size, resolution, in\_channels)\).
- Outputs:
output (Tensor) -Tensor of shape \((batch\_size, resolution, out\_channels)\).
- Raises
ValueError – If ff_weight_norm is not
False.
Examples
>>> import numpy as np >>> import mindspore >>> from mindspore import Tensor >>> import mindspore.common.dtype as mstype >>> from mindscience.models.neural_operator.ffno import FFNO2D >>> data = Tensor(np.ones([2, 128, 128, 3]), mstype.float32) >>> net = FFNO2D(in_channels=3, out_channels=3, n_modes=[20, 20], resolutions=[128, 128]) >>> out = net(data) >>> print(data.shape, out.shape) (2, 128, 128, 3) (2, 128, 128, 3)