mindspore.mint.nn.AdaptiveAvgPool2d
- class mindspore.mint.nn.AdaptiveAvgPool2d(output_size)[source]
Apply a 2-D adaptive average pooling over an input signal composed of several input planes.
The output is of size \(H \times W\), for any input size. The number of output features is equal to the number of input planes.
- Parameters
output_size (Union[int, tuple[int]]) – The target output size of the image of the form \(H \times W\). Can be a tuple \((H, W)\) or a single \(H\) for square image \(H \times H\). \(H\) and \(W\) can be either an
int, orNonewhich means the size will be the same as that of the input.
- Inputs:
input (Tensor) - The input tensor with shape \((N, C, H, W)\) or \((C, H, W)\).
- Outputs:
Tensor.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> input = mindspore.tensor([[[2, 1, 2], [2, 3, 5]]], mindspore.float16) >>> net = mindspore.mint.nn.AdaptiveAvgPool2d((2, 2)) >>> output = net(input) >>> print(output) [[[1.5 1.5] [2.5 4. ]]]