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.

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.

mindspore.nn.Conv3d

class mindspore.nn.Conv3d(in_channels, out_channels, kernel_size, stride=1, pad_mode='same', padding=0, dilation=1, group=1, has_bias=False, weight_init='normal', bias_init='zeros', data_format='NCDHW')[source]

Calculates the 3D convolution on the input tensor. The input is typically of shape (N,Cin,Din,Hin,Win), where N is batch size, Cin is a number of channels, Din,Hin,Win are the depth, height and width of the feature layer respectively. For the tensor of each batch, its shape is (Cin,Din,Hin,Win), the formula is defined as:

out(Ni,Coutj)=bias(Coutj)+k=0Cin1ccor(weight(Coutj,k),X(Ni,k))

where ccor is the cross-correlation, Cin is the channel number of the input, outj corresponds to the jth channel of the output and j is in the range of [0Cout1]. weight(Coutj,k) is a convolution kernel slice with shape (kernel_size[0],kernel_size[1],kernel_size[2]), where kernel_size[0], kernel_size[1] and kernel_size[2] are the depth, height and width of the convolution kernel respectively. bias is the bias parameter and X is the input tensor. The shape of full convolution kernel is (Cout,Cin/group,kernel_size[0],kernel_size[1],kernel_size[2]), where group is the number of groups to split the input x in the channel dimension.

For more details, please refers to the paper Gradient Based Learning Applied to Document Recognition.

Note

On Ascend platform, only group convolution in depthwise convolution scenarios is supported. That is, when group>1, condition in_channels = out_channels = group must be satisfied.

Parameters
  • in_channels (int) – The channel number of the input tensor of the Conv3d layer.

  • out_channels (int) – The channel number of the output tensor of the Conv3d layer.

  • kernel_size (Union[int, tuple[int]]) – Specifies the depth, height and width of the 3D convolution kernel. The data type is an integer or a tuple of three integers. An integer represents the depth, height and width of the convolution kernel. A tuple of three integers represents the depth, height and width of the convolution kernel respectively.

  • stride (Union[int, tuple[int]]) – The movement stride of the 3D convolution kernel. The data type is an integer or a tuple of three integers. An integer represents the movement step size in depth, height and width directions. A tuple of three integers represents the movement step size in the depth, height and width directions respectively. Default: 1.

  • pad_mode (str) –

    Specifies padding mode. The optional values are “same”, “valid”, “pad”. Default: “same”.

    • same: The width of the output is the same as the value of the input divided by stride. If this mode is set, the value of padding must be 0.

    • valid: Returns a valid calculated output without padding. Excess pixels that do not satisfy the calculation will be discarded. If this mode is set, the value of padding must be 0.

    • pad: Pads the input. Padding padding size of zero on both sides of the input. If this mode is set, the value of padding must be greater than or equal to 0.

  • padding (Union(int, tuple[int])) – The number of padding on the depth, height and width directions of the input. The data type is an integer or a tuple of six integers. If padding is an integer, then the head, tail, top, bottom, left, and right padding are all equal to padding. If padding is a tuple of six integers, then the head, tail, top, bottom, left, and right padding is equal to padding[0], padding[1], padding[2], padding[3], padding[4] and padding[5] respectively. The value should be greater than or equal to 0. Default: 0.

  • dilation (Union[int, tuple[int]]) – Dilation size of 3D convolution kernel. The data type is an integer or a tuple of three integers. If k>1, the kernel is sampled every k elements. The value of k on the depth, height and width directions is in range of [1, D], [1, H] and [1, W] respectively. Default: 1.

  • group (int) – Splits filter into groups, in_channels and out_channels must be divisible by group. Default: 1. Only 1 is currently supported.

  • has_bias (bool) – Whether the Conv3d layer has a bias parameter. Default: False.

  • weight_init (Union[Tensor, str, Initializer, numbers.Number]) – Initialization method of weight parameter. It can be a Tensor, a string, an Initializer or a numbers.Number. When a string is specified, values from ‘TruncatedNormal’, ‘Normal’, ‘Uniform’, ‘HeUniform’ and ‘XavierUniform’ distributions as well as constant ‘One’ and ‘Zero’ distributions are possible. Alias ‘xavier_uniform’, ‘he_uniform’, ‘ones’ and ‘zeros’ are acceptable. Uppercase and lowercase are both acceptable. Refer to the values of Initializer for more details. Default: ‘normal’.

  • bias_init (Union[Tensor, str, Initializer, numbers.Number]) – Initialization method of bias parameter. Available initialization methods are the same as ‘weight_init’. Refer to the values of Initializer for more details. Default: ‘zeros’.

  • data_format (str) – The optional value for data format. Currently only support “NCDHW”.

Inputs:
  • x (Tensor) - Tensor of shape (N,Cin,Din,Hin,Win). Currently input data type only support float16 and float32.

Outputs:

Tensor of shape is (N,Cout,Dout,Hout,Wout).

pad_mode is ‘same’:

DoutDinstride[0]HoutHinstride[1]WoutWinstride[2]

pad_mode is ‘valid’:

DoutDindilation[0]×(kernel_size[0]1)stride[0]+1HoutHindilation[1]×(kernel_size[1]1)stride[1]+1WoutWindilation[2]×(kernel_size[2]1)stride[2]+1

pad_mode is ‘pad’:

DoutDin+padding[0]+padding[1](dilation[0]1)×kernel_size[0]1stride[0]+1HoutHin+padding[2]+padding[3](dilation[1]1)×kernel_size[1]1stride[1]+1WoutWin+padding[4]+padding[5](dilation[2]1)×kernel_size[2]1stride[2]+1
Raises
  • TypeError – If in_channels, out_channels or group is not an int.

  • TypeError – If kernel_size, stride, padding or dilation is neither an int nor a tuple.

  • ValueError – If out_channels, kernel_size, stride or dilation is less than 1.

  • ValueError – If padding is less than 0.

  • ValueError – If pad_mode is not one of ‘same’, ‘valid’, ‘pad’.

  • ValueError – If padding is a tuple whose length is not equal to 6.

  • ValueError – If pad_mode is not equal to ‘pad’ and padding is not equal to (0, 0, 0, 0, 0, 0).

  • ValueError – If data_format is not ‘NCDHW’.

Supported Platforms:

Ascend GPU CPU

Examples

>>> x = Tensor(np.ones([16, 3, 10, 32, 32]), mindspore.float32)
>>> conv3d = nn.Conv3d(in_channels=3, out_channels=32, kernel_size=(4, 3, 3))
>>> output = conv3d(x)
>>> print(output.shape)
(16, 32, 10, 32, 32)