Apply the 2d average pooling.

  • If data_format is 'NCHW', excepts input shape \((N, C, H, W)\), and output shape is \((N, C, H_{\text{out}}, W_{\text{out}})\).
  • If data_format is 'NHWC', excepts input shape \((N, H, W, C)\), and output shape is \((N, H_{\text{out}}, W_{\text{out}}, C)\).
  • padding could be 'VALID', 'SAME' or explicit padding size.


x = tf.ones((1, 2, 2, 2))
y = tf.nn.avg_pool2d(x, ksize=2, strides=2)
assert y.shape == (1, 1, 1, 2)
  • input (dragon.Tensor) – The input tensor.
  • ksize (Union[int, Sequence[int]]) – The size of pooling window.
  • strides (Union[int, Sequence[int]]) – The stride of pooling window.
  • padding (Union[int, Sequence[int], str], optional, default='VALID') – The padding algorithm or size.
  • data_format (str, optional, default='NHWC') – 'NCHW' or 'NHWC'.
  • name (str, optional) – The operation name.

dragon.Tensor – The output tensor.