mindspore.ops.AdaptiveAvgPool3D
- class mindspore.ops.AdaptiveAvgPool3D(output_size)[源代码]
三维自适应平均池化。
警告
这是一个实验性API,后续可能修改或删除。
更多参考详见
mindspore.ops.adaptive_avg_pool3d()
。- 参数:
output_size (Union[int, tuple]) - 指定输出特征图的尺寸。可以为一个整数或者三元tuple。
- 输入:
x (Tensor) - AdaptiveAvgPool3D的输入,为五维或四维的Tensor。
- 输出:
Tensor,数据类型与 x 相同。
- 支持平台:
Ascend
GPU
CPU
样例:
>>> 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]]]]]