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.MaxPool3d

class mindspore.nn.MaxPool3d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)[source]

3D max pooling operation.

Applies a 3D max pooling over an input Tensor which can be regarded as a composition of 3D planes.

Typically the input is of shape (Nin,Cin,Din,Hin,Win), MaxPool outputs regional maximum in the (Din,Hin,Win)-dimension. Given kernel size is ks=(dker,hker,wker) and stride is s=(s0,s1,s2), the operation is as follows.

output(Ni,Cj,d,h,w)=maxl=0,,dker1maxm=0,,hker1maxn=0,,wker1input(Ni,Cj,s0×d+l,s1×h+m,s2×w+n)
Parameters
  • kernel_size (Union[int, tuple[int]]) – The size of kernel used to take the maximum value, is an int number that represents depth, height and width of the kernel, or a tuple of three int numbers that represent depth, height and width respectively. The value must be a positive integer.

  • stride (Union[int, tuple[int]]) – The moving stride of pooling operation, an int number that represents the moving stride of pooling kernel in the directions of depth, height and the width, or a tuple of three int numbers that represent depth, height and width of movement respectively. The value must be a positive integer. If the value is None, the default value kernel_size is used.

  • padding (Union[int, tuple[int]]) – Pooling padding length. An int number that represents the depth, height and width of movement are both stride, or a tuple of three int numbers that represent depth, height and width of movement respectively. The value cannot be negative. Default: 0.

  • dilation (Union[int, tuple[int]]) – Control the spacing of elements in the pooling kernel. Default: 1.

  • return_indices (bool) – If True, output is a Tuple of 2 Tensors, representing the maxpool result and where the max values are generated. Otherwise, only the maxpool result is returned. Default: False.

  • ceil_mode (bool) – Whether to use ceil or floor to calculate output shape. Default: False.

Inputs:
  • x (Tensor) - Tensor of shape (Nin,Cin,Din,Hin,Win) or (Cin,Din,Hin,Win) with data type of int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32 or float64.

Outputs:

If return_indices is False, output is a Tensor, with shape (N,C,Dout,Hout,Wout), or (Cout,Dout,Hout,Wout). It has the same data type as x.

If return_indices is True, output is a Tuple of 2 Tensors, representing the maxpool result and where the max values are generated.

  • output (Tensor) - Maxpooling result, with shape (Nout,Cout,Dout,Hout,Wout) or (Cout,Dout,Hout,Wout). It has the same data type as x.

  • argmax (Tensor) - Index corresponding to the maximum value. Data type is int64.

Raises
  • TypeError – If x is not a Tensor.

  • ValueError – If length of shape of x is not equal to 5.

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

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

  • ValueError – If padding is less than 0.

Supported Platforms:

GPU

Examples

>>> import mindspore as ms
>>> import mindspore.nn as nn
>>> import numpy as np
>>> pool1 = nn.MaxPool3d(kernel_size=3, stride=1, padding=1)
>>> pool2 = nn.MaxPool3d(kernel_size=3, stride=1, padding=1, return_indices=True)
>>> x = ms.Tensor(np.random.randint(0, 10, [1, 2, 2, 2, 2]), ms.float32)
>>> output1 = pool1(x)
>>> print(output1)
[[[[[8. 8.]
    [8. 8.]]
   [[8. 8.]
    [8. 8.]]]
  [[[9. 9.]
    [9. 9.]]
   [[9. 9.]
    [9. 9.]]]]]
>>> output2 = pool2(x)
>>> print(output2)
(Tensor(shape=[1, 2, 2, 2, 2], dtype=Float32, value=
[[[[[8.00000000e+000, 8.00000000e+000],
    [8.00000000e+000, 8.00000000e+000]],
   [[8.00000000e+000, 8.00000000e+000],
    [8.00000000e+000, 8.00000000e+000]]],
  [[[9.00000000e+000, 9.00000000e+000],
    [9.00000000e+000, 9.00000000e+000]],
   [[9.00000000e+000, 9.00000000e+000],
    [9.00000000e+000, 9.00000000e+000]]]]]), Tensor(shape=[1, 2, 2, 2, 2], dtype=Int64, value=
[[[[[7, 7],
    [7, 7]],
   [[7, 7],
    [7, 7]]],
  [[[2, 2],
    [2, 2]],
   [[2, 2],
    [2, 2]]]]]))