class
LPPool1d
extends
ModuleLPPool1d(norm_type: float, kernel_size: int, stride: int | None = None, ceil_mode: bool = False)Applies 1-D power-average (Lp-norm) pooling over a sequence.
For each window of length kernel_size the module computes the
norm of the absolute values of the elements:
where = norm_type, = kernel_size, and
= stride.
Special cases:
- — sum pooling (L1 norm over the window).
- — square-root of sum of squares (L2 norm).
- — approaches max pooling.
Parameters
norm_typefloatThe exponent . Must be positive and finite.
kernel_sizeintSize of the sliding window.
strideint or None= NoneStep between windows. Defaults to
kernel_size.ceil_modebool= FalseUse ceiling for output length. Default:
False.Attributes
norm_typefloatkernel_sizeintstrideintceil_modeboolNotes
- Input:
(N, C, L_in) - Output:
(N, C, L_out)where
- Lp pooling is a power-mean generalisation: it smoothly interpolates between sum pooling (), energy pooling (), and max pooling ().
- Because the operation is differentiable for finite , it can be used as a drop-in replacement for max or average pooling in gradient-based training.
- Implemented via engine primitives
unfold_dim,abs,pow_scalar, andsum— fully GPU-compatible.
Examples
L2 power pooling (energy pooling):
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.LPPool1d(norm_type=2, kernel_size=4)
>>> x = lucid.ones((1, 8, 16))
>>> y = pool(x)
>>> y.shape
(1, 8, 4)
Sum pooling (p=1) with overlapping windows:
>>> pool = nn.LPPool1d(norm_type=1, kernel_size=3, stride=1)
>>> x = lucid.ones((2, 4, 12))
>>> y = pool(x)
>>> y.shape
(2, 4, 10)Used by 1
Constructors
1Instance methods
2Return a string representation of the layer's configuration.