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.ops.MaxPoolWithArgmaxV2

class mindspore.ops.MaxPoolWithArgmaxV2(kernel_size, strides=None, pads=0, dilation=(1, 1), ceil_mode=False, argmax_type=mstype.int64)[source]

Performs max pooling on the input Tensor and returns both max values and indices.

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

output(Ni,Cj,h,w)=maxm=0,,hker1maxn=0,,wker1input(Ni,Cj,s0×h+m,s1×w+n)

Warning

This is an experimental API that is subject to change or deletion.

Parameters
  • kernel_size (Union[int, tuple[int]]) – The size of kernel used to take the maximum value and argmax value, is an int number that represents height and width of the kernel, or a tuple of two int numbers that represent height and width respectively.

  • strides (Union[int, tuple[int]], optional) – The distance of kernel moving, an int number that represents not only the height of movement but also the width of movement, or a tuple of two int numbers that represent height and width of movement respectively. Default: None, meaning that strides = kernel_size.

  • pads (Union[int, tuple[int]], optional) – An int number that represents the depth, height and width of movement are both strides, or a tuple of two int numbers that represent depth, height and width of movement respectively. Default: 0.

  • dilation (Union[int, tuple[int]], optional) – Control the stride of elements in the kernel. Default: ‘(1, 1)’.

  • ceil_mode (bool, optional) – Whether to use ceil instead of floor to calculate output shape. Default: False.

  • argmax_type (mindspore.dtype, optional) – The dtype for argmax. Default: mstype.int64. [Disabled in Ascend.]

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

Outputs:

Tuple of 2 Tensors, representing the maxpool result and where the max values are generated.

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

    Hout=Hin+2pads[0]dilation[0]×(kernel_size[0]1)1strides[0]+1
    Wout=Win+2pads[1]dilation[1]×(kernel_size[1]1)1strides[1]+1
  • argmax (Tensor) - Index corresponding to the maximum value. Data type is int32 or int64 in CPU and GPU, is uint16 in Ascend.

Raises
  • TypeError – If x is not a Tensor.

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

  • TypeError – If kernel_size , strides , pads or dilation is not int or tuple.

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

  • ValueError – If pads is less than 0.

  • ValueError – If pads is more than half of kernel_size.

  • ValueError – If argmax_type is not mindspore.int64 or mindspore.int32.

  • TypeError – If ceil_mode is not bool.

Supported Platforms:

Ascend GPU CPU

Examples

>>> x = Tensor(np.arange(20 * 16 * 50 * 32).reshape((20, 16, 50, 32)), mindspore.float32)
>>> maxpool_arg_v2_op = ops.MaxPoolWithArgmaxV2(kernel_size=(3, 2), strides=(2, 1))
>>> output_tensor, argmax = maxpool_arg_v2_op(x)
>>> print(output_tensor.shape)
(20, 16, 24, 31)
>>> print(argmax.shape)
(20, 16, 24, 31)