lp_pool1d(input: Tensor, norm_type: float, kernel_size: int | tuple[int], stride: int | tuple[int] | None = None, ceil_mode: bool = False)1-D power-average pooling — .
Generalises average and max pooling under a single parameter
. recovers
sum-pooling (= |R| × avg_pool1d); is
energy / RMS-style pooling; is
max_pool1d of .
Parameters
inputTensorInput of shape
(N, C, L), or (C, L) unbatched.norm_typefloatExponent , or
inf.kernel_sizeint or tuple of intSize of the pooling window.
strideint or tuple of 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, L_out).
Notes
Math (per window ):
The power keeps the sign of , as the reference's does: it is
the norm of the window only for a non-negative input or
an even . A window whose sum is negative, or a negative
element under a fractional , gives nan; pool
lucid.abs(x) for the norm. A window whose sum is zero has a zero
gradient. Computed as (avg_pool1d(x^p) · |R|)^(1/p).
Examples
>>> import lucid
>>> from lucid.nn.functional import lp_pool1d
>>> x = lucid.randn(2, 4, 12)
>>> y = lp_pool1d(x, norm_type=2.0, kernel_size=2)
>>> y.shape
(2, 4, 6)