# 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


__init__(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)
 __call__(*args, **kwargs) Call self as a function. __delattr__(name, /) Implement delattr(self, name). __dir__() Default dir() implementation. __eq__(value, /) Return self==value. __format__(format_spec, /) Default object formatter. __ge__(value, /) Return self>=value. __getattr__(name) __getattribute__(name, /) Return getattr(self, name). __gt__(value, /) Return self>value. __hash__() Return hash(self). __init__(kernel_size[, stride, padding, …]) Initialize self. __init_subclass__ This method is called when a class is subclassed. __le__(value, /) Return self<=value. __lt__(value, /) Return self