avg_pool2d

dragon.vm.tensorflow.nn.avg_pool2d(
  input,
  ksize,
  strides,
  padding='VALID',
  data_format='NHWC',
  name=None
)[source]

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.

Examples:

x = tf.ones((1, 2, 2, 2))
y = tf.nn.avg_pool2d(x, ksize=2, strides=2)
assert y.shape == (1, 1, 1, 2)
Parameters:
  • 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.
Returns:

dragon.Tensor The output tensor.