oneflow.nn.AvgPool2d¶
-
class
oneflow.nn.
AvgPool2d
(kernel_size: Union[int, Tuple[int, int]], stride: Optional[Union[int, Tuple[int, int]]] = None, padding: Union[int, Tuple[int, int]] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int = 0)¶ Performs the 2d-average pooling on the input.
In the simplest case, the output value of the layer with input size \((N, C, H, W)\), output \((N, C, H_{out}, W_{out})\) and kernel_size \((kH, kW)\) can be precisely described as:
\[out(N_i, C_j, h, w) = \frac{1}{kH * kW} \sum_{m=0}^{kH-1} \sum_{n=0}^{kW-1} input(N_i, C_j, stride[0] \times h + m, stride[1] \times w + n)\]- Parameters
kernel_size (Union[int, Tuple[int, int]]) – An int or list of ints that has length 1, 2. The size of the window for each dimension of the input Tensor.
strides (Union[int, Tuple[int, int]]) – An int or list of ints that has length 1, 2. The stride of the sliding window for each dimension of the input Tensor.
padding (Tuple[int, int]) – An int or list of ints that has length 1, 2. Implicit zero padding to be added on both sides.
ceil_mode (bool, default to False) – When True, will use ceil instead of floor to compute the output shape.
For example:
import oneflow as flow import numpy as np m = flow.nn.AvgPool2d(kernel_size=3, padding=1, stride=1) x = flow.tensor(np.random.randn(1, 4, 4, 4)) y = m(x) y.shape oneflow.Size([1, 4, 4, 4])