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.

mindspore.ops.AvgPool3D

View Source On Gitee
class mindspore.ops.AvgPool3D(kernel_size=1, strides=1, pad_mode='valid', pad=0, ceil_mode=False, count_include_pad=True, divisor_override=0, data_format='NCDHW')[source]

3D Average pooling operation.

Typically the input is of shape (N,C,Din,Hin,Win), AvgPool3D outputs regional average in the (Din,Hin,Win)-dimension. Given kernel size ks=(dker,hker,wker) and stride s=(s0,s1,s2), the operation is as follows:

output(Ni,Cj,d,h,w)=1dkerhkerwkerl=0dker1m=0hker1n=0wker1input(Ni,Cj,s0×d+l,s1×h+m,s2×w+n)

Note

This interface currently does not support Atlas A2 training series products.

Parameters
  • kernel_size (Union[int, tuple[int]], optional) – The size of kernel used to take the average value, is an int number that represents depth, height and width are both kernel_size, or a tuple of three int numbers that represent depth, height and width respectively. Default: 1 . The value range is: [1, 255].

  • strides (Union[int, tuple[int]], optional) – The distance of kernel moving, an int number that represents the depth, height and width of movement are both strides, or a tuple of three int numbers that represent depth, height and width of movement respectively. Default: 1 . The value range is: [1, 63].

  • pad_mode (str, optional) –

    Specifies the padding mode with a padding value of 0. It can be set to: "same" , "valid" or "pad" . Default: "valid" .

    • "same": Pad the input around its depth/height/width dimension so that the shape of input and output are the same when stride is set to 1. The amount of padding to is calculated by the operator internally. If the amount is even, it isuniformly distributed around the input, if it is odd, the excess amount goes to the front/right/bottom side. If this mode is set, pad must be 0.

    • "valid": No padding is applied to the input, and the output returns the maximum possible depth, height and width. Extra pixels that could not complete a full stride will be discarded. If this mode is set, pad must be 0.

    • "pad": Pad the input with a specified amount. In this mode, the amount of padding in the depth, height and width dimension is determined by the pad parameter. If this mode is set, pad must be greater than or equal to 0.

  • pad (Union(int, tuple[int], list[int]), optional) – The pad value to be filled. Default: 0 . If pad is an integer, the paddings of head, tail, top, bottom, left and right are the same, equal to pad. If pad is a tuple of six integers, the padding of head, tail, top, bottom, left and right equal to pad[0], pad[1], pad[2], pad[3], pad[4] and pad[5] correspondingly.

  • ceil_mode (bool, optional) – If True , ceil instead of floor to compute the output shape. Default: False .

  • count_include_pad (bool, optional) – If True , averaging calculation will include the zero-padding. Default: True .

  • divisor_override (int, optional) – If specified, it will be used as divisor in the averaging calculation, otherwise kernel_size will be used. Default: 0 .

  • data_format (str, optional) – The optional value for data format. Currently only support 'NCDHW' . Default: 'NCDHW' .

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

Outputs:

Tensor, with shape (N,C,Dout,Hout,Wout). Has the same data type with x.

Raises
  • TypeError – If kernel_size, strides or pad is neither an int not a tuple.

  • TypeError – If ceil_mode or count_include_pad is not a bool.

  • TypeError – If pad_mode or data_format is not a string.

  • TypeError – If divisor_override is not an int.

  • ValueError – If numbers in kernel_size or strides are not positive.

  • ValueError – If kernel_size or strides is a tuple whose length is not equal to 3.

  • ValueError – If pad_mode is not one of 'same', 'valid' or 'pad'.

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

  • ValueError – If element of pad is less than 0.

  • ValueError – If pad_mode is not equal to 'pad' and pad is not equal to 0 or (0, 0, 0, 0, 0, 0).

  • ValueError – If data_format is not 'NCDHW'.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> from mindspore import Tensor, ops
>>> import numpy as np
>>> x = Tensor(np.arange(1 * 2 * 2 * 2 * 3).reshape((1, 2, 2, 2, 3)), mindspore.float16)
>>> avg_pool3d = ops.AvgPool3D(kernel_size=2, strides=1, pad_mode="valid")
>>> output = avg_pool3d(x)
>>> print(output)
[[[[[ 5.  6.]]]
  [[[17. 18.]]]]]