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.
Special cases (same as LPPool1d):
- — sum pooling.
- — Euclidean (energy) pooling.
- — max pooling.
Parameters
norm_typefloatThe exponent .
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
- Implemented as two sequential
unfold_dimpasses (H-axis then W-axis) followed by element-wise power, reduction, and inverse power. Fully GPU-compatible via engine primitives. - 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.