mindspore.ops.AdaptiveAvgPool3D

View Source On Gitee
class mindspore.ops.AdaptiveAvgPool3D(output_size)[source]

AdaptiveAvgPool3D operation.

Warning

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

Refer to mindspore.ops.adaptive_avg_pool3d() for more details.

Parameters

output_size (Union[int, tuple]) – Specify the size of output tensor. It can be a single int or a tuple of three ints.

Inputs:
  • x (Tensor) - The input of AdaptiveAvgPool3D, which is a 5D or 4D tensor.

Outputs:

Tensor, with the same type as the x.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import nn, Tensor
>>> from mindspore.ops import AdaptiveAvgPool3D
>>> class AdaptiveAvgPool3DNet(nn.Cell):
...     def __init__(self, output_size):
...         super(AdaptiveAvgPool3DNet, self).__init__()
...         self.output_size_ = output_size
...         self.adaptive_avg_pool_3d = AdaptiveAvgPool3D(self.output_size_)
...     def construct(self, x_):
...         return self.adaptive_avg_pool_3d(x_)
...
>>> output_size=(1,1,1)
>>> input_x_val = np.zeros((1,1,2,2,2))
>>> input_x_val[:,:,0,:,:]  += 1
>>> input_x = Tensor(input_x_val, mindspore.float32)
>>> adaptive_avg_pool_3d = AdaptiveAvgPool3DNet(output_size)
>>> output = adaptive_avg_pool_3d(input_x)
>>> print(output)
[[[[[0.5]]]]]