pool¶
dragon.nn.pool(
inputs,
kernel_shape,
strides,
pads=0,
padding='VALID',
mode='max',
global_pool=False,
ceil_mode=False,
data_format='NCHW',
**kwargs
)[source]¶Apply the n-dimension pooling.
- Set
modefor the specific pooling type, default ismaxpool. - Use
global_poolto apply the global pooling further. - If
data_formatis'NCHW', excepts input shape \((N, C, D1, D2, ...)\), and output shape is \((N, C, D1_{\text{out}}, D2_{\text{out}}, ...)\). - If
data_formatis'NHWC', excepts input shape \((N, D1, D2, ..., C)\), and output shape is \((N, D1_{\text{out}}, D2_{\text{out}}, ..., C)\). - If
paddingis'VALID',padscontrols the explicit padding size. Otherwise, size are computed automatically use the given method.
Examples:
for i in range(3): ndim = i + 1 x = dragon.ones((1, 2) + (2,) * ndim) y = dragon.nn.pool(x, kernel_shape=(2,) * ndim, strides=2) assert y.shape == (1, 2) + (1,) * ndim
- Parameters:
- inputs (dragon.Tensor) – The input tensor.
- kernel_shape (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