fn
max_pool1d
→Tensormax_pool1d(x: Tensor, kernel_size: int | tuple[int, ...], stride: int | tuple[int, ...] | None = None, padding: int | tuple[int, ...] = 0, dilation: int | tuple[int, ...] = 1, return_indices: bool = False, ceil_mode: bool = False)1-D max pooling over a sliding window.
For each window, takes the maximum value — a translation-invariant feature aggregator that also provides a degree of non-linearity. Standard ingredient of 1-D temporal CNNs (text, audio, sensor data).
Parameters
xTensorInput of shape
(N, C, L).kernel_sizeint or tuple of intSize of the pooling window.
strideint or tuple of int= NoneWindow step. Defaults to
kernel_size (non-overlapping).paddingint or tuple of int= 0Implicit zero-padding on both sides of the spatial axis.
dilationint or tuple of int= 1Spacing between window elements. Default
1.return_indicesbool= FalseCurrently must be
False; the engine pool op does not yet
emit per-window argmax indices.ceil_modebool= FalseWhen
True, use ceil instead of floor in the output-size
formula.Returns
TensorOutput of shape (N, C, L_out) where
Notes
Math:
Max-pool is sub-differentiable: the gradient flows only through the position(s) holding the maximum in each window.
Examples
>>> import lucid
>>> from lucid.nn.functional import max_pool1d
>>> x = lucid.randn(2, 4, 16)
>>> y = max_pool1d(x, kernel_size=2)
>>> y.shape
(2, 4, 8)