Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindflow.cell.PeRCNN

View Source On Gitee
class mindflow.cell.PeRCNN(dim, in_channels, hidden_channels, kernel_size, dt, nu, laplace_kernel=None, conv_layers_num=3, padding='periodic', compute_dtype=ms.float32)[source]

Recurrent convolutional neural network Cell. lazy_inline is used to accelerate the compile stage, but now it only functions in Ascend backends. PeRCNN currently supports input with two physical components. For inputs with different shape, users must manually add or remove corresponding parameters and pi_blocks.

Parameters
  • dim (int) – The physical dimension of input. Length of the shape of a 2D input is 4, of a 3D input is 5. Data follows NCHW or NCDHW format.

  • kernel_size (int) – Specifies the convolution kernel for parallel convolution layers.

  • in_channels (int) – The number of channels in the input space.

  • hidden_channels (int) – Number of channels in the output space of parallel convolution layers.

  • dt (int, float) – The time step of PeRCNN.

  • nu (int, float) – The coefficient of diffusion term.

  • padding (str) – Boundary padding. Now only periodic padding is supported. Default: periodic

  • laplace_kernel (mindspore.Tensor) – For 3D, Set size of kernel is :math:`(text{kernel_size[0]},

  • text{kernel_size[1]} – math:`(C_{out}, C_{in},

  • text{kernel_size[2]})` – math:`(C_{out}, C_{in},

  • is (then the shape) – math:`(C_{out}, C_{in},

  • text{kernel_size[0]}(N,Cin/groups,kernel_size[0],kernel_size[1]), then the size of kernel is (kernel_size[0],kernel_size[1]).

  • text{kernel_size[1]}(N,Cin/groups,kernel_size[0],kernel_size[1]), then the size of kernel is (kernel_size[0],kernel_size[1]).

  • 2D (text{kernel_size[1]})`. For) – (N,Cin/groups,kernel_size[0],kernel_size[1]), then the size of kernel is (kernel_size[0],kernel_size[1]).

  • shape (Tensor of) – (N,Cin/groups,kernel_size[0],kernel_size[1]), then the size of kernel is (kernel_size[0],kernel_size[1]).

  • conv_layers_num (int) – Number of parallel convolution layers. Default: 3.

  • compute_dtype (dtype.Number) – The data type of PeRCNN. Default: mindspore.float32. Should be mindspore.float16 or mindspore.float32. mindspore.float32 is recommended for GPU backends, mindspore.float16 is recommended for Ascend backends.

Inputs:
input (Tensor) - Tensor of shape (batch_size,channels,depth,height,width) for 3D.

Tensor of shape (batch_size,channels,height,width) for 2D.

Outputs:

Tensor, has the same shape as input.

Raises
  • TypeError – If dim, in_channels, hidden_channels, kernel_size is not an int.

  • TypeError – If dt and nu is not an int nor a float.

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> import mindspore as ms
>>> from mindflow.cell.neural_operators.percnn import PeRCNN
>>> laplace_3d = [[[[[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0],
>>>                 [0.0, 0.0, -0.08333333333333333, 0.0, 0.0],
>>>                 [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]],
>>>                 [[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0],
>>>                 [0.0, 0.0, 1.3333333333333333, 0.0, 0.0],
>>>                 [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]],
>>>                 [[0.0, 0.0, -0.08333333333333333, 0.0, 0.0],
>>>                 [0.0, 0.0, 1.3333333333333333, 0.0, 0.0],
>>>                 [-0.08333333333333333, 1.3333333333333333, -7.5, 1.3333333333333333, -0.08333333333333333],
>>>                 [0.0, 0.0, 1.3333333333333333, 0.0, 0.0],
>>>                 [0.0, 0.0, -0.08333333333333333, 0.0, 0.0]],
>>>                 [[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0],
>>>                 [0.0, 0.0, 1.3333333333333333, 0.0, 0.0],
>>>                 [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]],
>>>                 [[0.0, 0.0, 0.0, 0.0, 0.0],
>>>                 [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, -0.08333333333333333, 0.0, 0.0],
>>>                 [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]]]]]
>>> laplace = np.array(laplace_3d)
>>> grid_size = 48
>>> field = 100
>>> dx_3d = field / grid_size
>>> laplace_3d_kernel = ms.Tensor(1 / dx_3d**2 * laplace, dtype=ms.float32)
>>> rcnn_ms = PeRCNN(
>>>     dim=3,
>>>     in_channels=2,
>>>     hidden_channels=2,
>>>     kernel_size=1,
>>>     dt=0.5,
>>>     nu=0.274,
>>>     laplace_kernel=laplace_3d_kernel,
>>>     conv_layers_num=3,
>>>     compute_dtype=ms.float32,
>>>   )
>>> input = np.random.randn(1, 2, 48, 48, 48)
>>> input = ms.Tensor(input, ms.float32)
>>> output = rcnn_ms(input)
>>> print(output.shape)

(1, 2, 48, 48, 48)