avg_pool1d#

ivy.avg_pool1d(x, kernel, strides, padding, /, *, data_format='NWC', count_include_pad=False, ceil_mode=False, division_override=None, out=None)[source]#

Compute a 1-D avg pool given 3-D input x.

Parameters:
  • x (Union[Array, NativeArray]) – Input image [batch_size, w, d_in].

  • kernel (Union[int, Tuple[int]]) – Size of the kernel i.e., the sliding window for each dimension of input. [w].

  • strides (Union[int, Tuple[int]]) – The stride of the sliding window for each dimension of input.

  • padding (str) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (str) – NWC” or “NCW”. Defaults to “NWC”. (default: 'NWC')

  • count_include_pad (bool) – Whether to include padding in the averaging calculation. (default: False)

  • ceil_mode (bool) – Whether to use ceil or floor for creating the output shape. (default: False)

  • division_override (Optional[int]) – If specified, it will be used as the divisor, (default: None) otherwise kernel_size will be used.

  • out (Optional[Array]) – optional output array, for writing the result to. (default: None)

Return type:

Array

Returns:

  • ret – The result of the pooling operation.

  • Both the description and the type hints above assumes an array input

  • for simplicity, but this function is *nestable, and therefore*

  • also accepts ivy.Container instances in place of any of

  • the arguments.

Examples

>>> x = ivy.arange(0, 24.).reshape((2, 3, 4))
>>> print(ivy.avg_pool1d(x, 2, 2, 'SAME'))
ivy.array([[[ 2.,  3.,  4.,  5.],
        [ 8.,  9., 10., 11.]],
[[14., 15., 16., 17.],

[20., 21., 22., 23.]]])

>>> x = ivy.arange(0, 24.).reshape((2, 3, 4))
>>> print(ivy.avg_pool1d(x, 2, 2, 'VALID'))
ivy.array([[[ 2.,  3.,  4.,  5.]],

[[14., 15., 16., 17.]]])

Array.avg_pool1d(self, kernel, strides, padding, /, *, data_format='NWC', count_include_pad=False, ceil_mode=False, out=None)#

ivy.Array instance method variant of ivy.avg_pool1d. This method simply wraps the function, and so the docstring for ivy.avg_pool1d also applies to this method with minimal changes.

Parameters:
  • self (Array) – Input image [batch_size,w,d_in].

  • kernel (Union[int, Tuple[int]]) – The size of the window for each dimension of the input tensor.

  • strides (Union[int, Tuple[int]]) – The stride of the sliding window for each dimension of input.

  • padding (str) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (str) – “NWC” or “NCW”. Defaults to “NWC”. (default: 'NWC')

  • count_include_pad (bool) – Whether to include padding in the averaging calculation. (default: False)

  • ceil_mode (bool) – Whether to use ceil or floor for creating the output shape. (default: False)

  • out (Optional[Array]) – optional output array, for writing the result to. It must have a shape that (default: None) the inputs broadcast to.

Return type:

Array

Returns:

ret – The result of the max pooling operation.

Examples

>>> x = ivy.arange(0, 24.).reshape((2, 3, 4))
>>> print(x.avg_pool1d(2, 2, 'SAME'))
ivy.array([[[ 2.,  3.,  4.,  5.],
        [ 8.,  9., 10., 11.]],
       [[14., 15., 16., 17.],
        [20., 21., 22., 23.]]])
>>> x = ivy.arange(0, 24.).reshape((2, 3, 4))
>>> print(x.avg_pool1d(2, 2, 'VALID'))
ivy.array([[[ 2.,  3.,  4.,  5.]],
       [[14., 15., 16., 17.]]])
Container.avg_pool1d(self, kernel, strides, padding, /, *, data_format='NWC', count_include_pad=False, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#

ivy.Container instance method variant of ivy.avg_pool1d. This method simply wraps the function, and so the docstring for ivy.avg_pool1d also applies to this method with minimal changes.

Parameters:
  • self (Container) – Container of input images [batch_size, w, d_in].

  • kernel (Union[int, Tuple[int]]) – Size of the kernel i.e., the sliding window for each dimension of input. [w].

  • strides (Union[int, Tuple[int]]) – The stride of the sliding window for each dimension of input.

  • padding (str) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (str) – NWC” or “NCW”. Defaults to “NWC”. (default: 'NWC')

  • count_include_pad (bool) – Whether to include padding in the averaging calculation. (default: False)

  • ceil_mode (bool) – Whether to use ceil or floor for creating the output shape. (default: False)

  • out (Optional[Container]) – optional output array, for writing the result to. (default: None)

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12.).reshape((2,2,3))
>>> b = ivy.arange(24.).reshape((2,3,4))
>>> x = ivy.Container({'a': a, 'b': b})
>>> print(x.avg_pool1d(2, 2, "VALID"))
{
    a: ivy.array([[[1.5, 2.5, 3.5]],
                  [[7.5, 8.5, 9.5]]]),
    b: ivy.array([[[2., 3., 4., 5.]],
                  [[14., 15., 16., 17.]]])
}