mindspore.mint.nn.functional.avg_pool3d

View Source On Gitee
mindspore.mint.nn.functional.avg_pool3d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None)[source]

Applies a 3D average pooling over an input Tensor which can be regarded as a composition of 3D input planes. Typically the input is of shape (N,C,Din,Hin,Win) , outputs regional average in the (Din,Hin,Win) -dimension. Given kernel size (kD,kH,kW) and stride , the operation is as follows.

output(Ni,Cj,d,h,w)=1kDkHkWl=0kD1m=0kH1n=0kW1input(Ni,Cj,stride[0]×d+l,stride[1]×h+m,stride[2]×w+n)

Warning

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

Note

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

Parameters
  • input (Tensor) – Tensor of shape (N,C,Din,Hin,Win) or (C,Din,Hin,Win).

  • kernel_size (Union[int, tuple[int], list[int]]) – The size of kernel used to take the average value. Can be a single number or a tuple (kD,kH,kW) .

  • stride (Union[int, tuple[int], list[int]], optional) – The distance of kernel moving. Can be a single number or a tuple (sD,sH,sW) . Default: None, where its value is equal to kernel_size.

  • padding (Union[int, tuple[int], list[int]], optional) – Implicit zero padding to be added on both sides. Can be a single number or a tuple (padD,padH,padW) . Default: 0.

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

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

  • divisor_override (int, optional) – If specified, it will be used as divisor in the averaging calculation, otherwise size of pooling region will be used. Default: None.

Returns

Tensor, with shape (N,C,Dout,Hout,Wout) or (C,Dout,Hout,Wout).

Dout=Din+2×padding[0]kernel_size[0]stride[0]+1Hout=Hin+2×padding[1]kernel_size[0]stride[1]+1Wout=Win+2×padding[2]kernel_size[1]stride[2]+1

Raises
  • TypeError – If input is not a Tensor.

  • TypeError – If kernel_size or stride is neither int nor tuple.

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

  • TypeError – If divisor_override is not an int or None.

  • ValueError – If the dimension of input is not equal to 4 or 5.

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

  • ValueError – If value of padding is less than 0.

  • ValueError – If kernel_size, padding or stride is a tuple whose length is not equal to 1 or 3.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> input_x = Tensor(np.arange(1 * 2 * 2 * 2 * 3).reshape((1, 2, 2, 2, 3)), mindspore.float16)
>>> output = mint.nn.functional.avg_pool3d(input_x, kernel_size=2, stride=1)
>>> print(output)
[[[[[ 5.  6.]]]
  [[[17. 18.]]]]]