pool2d¶
dragon.nn.
pool2d
(
inputs,
kernel_shape,
strides,
pads=0,
padding='VALID',
mode='max',
global_pool=False,
ceil_mode=False,
data_format='NCHW',
**kwargs
)[source]¶Apply the 2d pooling.
- Set
mode
for the specific pooling type, default ismaxpool
. - Use
global_pool
to apply the global pooling further. - 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)\). - If
padding
is'VALID'
,pads
controls the explicit padding size. Otherwise, size are computed automatically use the given method.
Examples:
x = dragon.ones((1, 2, 2, 2)) y = dragon.nn.pool2d(x, kernel_shape=2, strides=2) assert y.shape == (1, 2, 1, 1)
- Parameters:
- inputs (dragon.Tensor) – The input tensor.
- kernel_shape (Union[int, Sequence[int]], required) – The shape of pooling window.
- strides (Union[int, Sequence[int]], required) – The stride of pooling window.
- pads (Union[int, Sequence[int]], optional, default=0) – The zero padding size.
- padding (str, optional, default='VALID') –
'VALID'
,'SAME'
,'SAME_UPPER'
or'SAME_LOWER'
. - mode (str, optional, default='max') –
'max'
or'avg'
. - global_pool (bool, optional, default=False) – Apply the global pooling or not.
- ceil_mode (bool, optional, default=False) – Ceil or floor the boundary.
- data_format (str, optional, default='NCHW') –
'NCHW'
or'NHWC'
.
- Returns:
dragon.Tensor – The output tensor.
- Set