mindspore/docs/api/api_python/nn/mindspore.nn.AdaptiveAvgPoo...

36 lines
1.7 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.nn.AdaptiveAvgPool2d
==============================
.. py:class:: mindspore.nn.AdaptiveAvgPool2d(output_size)
2维自适应平均池化。
对输入Tensor提供2维的自适应平均池化操作。也就是说对于输入任何尺寸指定输出的尺寸都为H * W。但是输入和输出特征的数目不会变化。
输入和输出数据格式可以是"NCHW"和"CHW"。N是批处理大小C是通道数H是特征高度W是特征宽度。运算如下
.. math::
\begin{align}
h_{start} &= floor(i * H_{in} / H_{out})\\
h_{end} &= ceil((i + 1) * H_{in} / H_{out})\\
w_{start} &= floor(j * W_{in} / W_{out})\\
w_{end} &= ceil((j + 1) * W_{in} / W_{out})\\
Output(i,j) &= \frac{\sum Input[h_{start}:h_{end}, w_{start}:w_{end}]}{(h_{end}- h_{start})
* (w_{end}- w_{start})}
\end{align}
参数:
- **output_size** (Union[int, tuple]) - 输出特征图的尺寸为H * W。可以是int类型的H和W组成的tuple也可以为一个int值代表相同H和W或None如果是None则意味着输出大小与输入相同。
输入:
- **x** (Tensor) - AdaptiveAvgPool2d的输入为三维或四维的Tensor数据类型为float16、float32或者float64。
输出:
Tensor输出shape为 :math:`(N, C_{out}, H_{out}, W_{out})`
异常:
- **ValueError** - 如果 `output_size` 是tuple并且 `output_size` 的长度不是2。
- **TypeError** - 如果 `x` 不是Tensor。
- **TypeError** - 如果 `x` 的数据类型不是float16、float32或者float64。
- **ValueError** - 如果 `x` 的维度小于或等于 `output_size` 的维度。