mindspore.ops.avg_pool3d

mindspore.ops.avg_pool3d(input_x, kernel_size=1, stride=1, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=0)[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), avg_pool3d 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)

Warning

kernel_size is in the range [1, 255]. stride is in the range [1, 63].

Parameters
  • input_x (Tensor) – Tensor of shape (N,C,Din,Hin,Win). Currently support float16 and float32 data type.

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

  • stride (Union[int, tuple[int]], optional) – The distance of kernel moving, 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. Default: 1.

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

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

Returns

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

Raises
  • TypeError – If input_x is not an Tensor.

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

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

  • TypeError – If divisor_override is not an int.

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

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

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

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

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

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.arange(1 * 2 * 2 * 2 * 3).reshape((1, 2, 2, 2, 3)), mindspore.float16)
>>> output = ops.avg_pool3d(input_x, kernel_size=2, stride=1)
>>> print(output)
[[[[[ 5.  6.]]]
  [[[17. 18.]]]]]