fn
lp_pool2d
→Tensorlp_pool2d(x: Tensor, norm_type: float, kernel_size: int | tuple[int, int], stride: int | tuple[int, int] | None = None, ceil_mode: bool = False)2-D Lp-norm pooling — .
Two-dimensional version of lp_pool1d. The exponent
interpolates between sum / average pooling (small
) and max pooling (large ), giving the network
a tunable "softness" parameter.
Parameters
xTensorInput of shape
(N, C, H, W).norm_typefloatExponent .
kernel_sizeint or (int, int)Size of the pooling window.
strideint or (int, int)= NoneWindow step. Defaults to
kernel_size.ceil_modebool= FalseUse ceil instead of floor in the output-size formula.
Returns
TensorOutput of shape (N, C, H_out, W_out).
Notes
Math (per window ):
The operator is fully differentiable for any .
Examples
>>> import lucid
>>> from lucid.nn.functional import lp_pool2d
>>> x = lucid.randn(1, 8, 16, 16)
>>> y = lp_pool2d(x, norm_type=3.0, kernel_size=2)
>>> y.shape
(1, 8, 8, 8)