class
LPPool2d
extends
ModuleLPPool2d(norm_type: float, kernel_size: int | tuple[int, int], stride: int | tuple[int, int] | None = None, ceil_mode: bool = False)Applies 2-D power-average (Lp-norm) pooling over a spatial feature map.
For each window the module computes:
with = norm_type. The power keeps the sign of ,
and the special cases are those of
LPPool1d.
Parameters
norm_typefloatThe exponent . Must be positive;
inf is allowed.kernel_sizeint or tuple[int, int]Window size
(k_H, k_W). A scalar is broadcast.strideint or tuple[int, int] or None= NoneStep between windows. Defaults to
kernel_size.ceil_modebool= FalseUse ceiling for output sizes. Default:
False.Attributes
norm_typefloatkhintKernel height.
kwintKernel width.
shintStride along the height dimension.
swintStride along the width dimension.
ceil_modeboolNotes
- Input:
(N, C, H_in, W_in) - Output:
(N, C, H_out, W_out)where
- Lp pooling with appears in energy-based models and certain biologically-inspired convolutional architectures.
Examples
L2 energy pooling:
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.LPPool2d(norm_type=2, kernel_size=2, stride=2)
>>> x = lucid.ones((1, 32, 16, 16))
>>> y = pool(x)
>>> y.shape
(1, 32, 8, 8)
Asymmetric window with p=1 (sum pooling):
>>> pool = nn.LPPool2d(norm_type=1, kernel_size=(3, 1), stride=(1, 1))
>>> x = lucid.ones((2, 16, 10, 8))
>>> y = pool(x)
>>> y.shape
(2, 16, 8, 8)Used by 1
Constructors
1Instance methods
2Return a string representation of the layer's configuration.