pool#
- ivy.pool(x, window_shape, pool_type, /, *, strides=None, padding='VALID', data_format=None, dilations=None, ceil_mode=False, out=None)[source]#
Perform an N-D pooling operation.
- Parameters:
x (
Union
[Array
,NativeArray
]) – Input array to pool over.window_shape (
Union
[int
,Tuple
[int
],Tuple
[int
,int
]]) – Shape of the pooling window.pool_type (
str
) – Type of pooling operation, either ‘MAX’ or ‘AVG’.strides (
Optional
[Union
[int
,Tuple
[int
],Tuple
[int
,int
]]], default:None
) – Strides of the pooling operation.padding (
str
, default:'VALID'
) – Padding type, either ‘VALID’ or ‘SAME’.data_format (
Optional
[str
], default:None
) – Data format of the input and output data, either ‘NCHW’ or ‘NHWC’.dilations (
Optional
[Union
[int
,Tuple
[int
],Tuple
[int
,int
]]], default:None
) – Dilation rate of the pooling operation.ceil_mode (
bool
, default:False
) – Whether to use ceil or floor for creating the output shape.out (
Optional
[Array
], default:None
) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
- Returns:
ret – The result of the pooling operation.
Examples
>>> x = ivy.arange(12.).reshape((2, 1, 3, 2)) >>> print(ivy.pool(x, (2, 2), 'MAX', strides=(1, 1), padding='SAME')) ivy.array([[[[ 1., 2.], [ 3., 4.], [ 4., 5.]]], [[[ 7., 8.], [ 9., 10.], [10., 11.]]]]) >>> x = ivy.arange(48.).reshape((2, 4, 3, 2)) >>> print(ivy.pool(x, 3, 'AVG', strides=1, padding='VALID')) ivy.array([[[[ 8., 9.]], [[14., 15.]]], [[[32., 33.]], [[38., 39.]]]])