fn
adaptive_max_pool1d
→Tensoradaptive_max_pool1d(x: Tensor, output_size: int | tuple[int, ...], return_indices: bool = False)1-D adaptive max pooling — produces a fixed output length.
Computes kernel / stride dynamically so the output length equals
output_size regardless of input length, then takes the
per-window maximum. Common in NLP / audio CNNs that feed
fixed-size embeddings into a head.
Parameters
xTensorInput of shape
(N, C, L).output_sizeint or tuple of intDesired output length.
return_indicesbool= FalseMust currently be
False.Returns
TensorOutput of shape (N, C, output_size).
Notes
The window for output index is
and the cell takes the max over that window. Equivalent to
max_pool1d with kernel == stride == L / L_out when the
division is exact.
Examples
>>> import lucid
>>> from lucid.nn.functional import adaptive_max_pool1d
>>> x = lucid.randn(2, 8, 21)
>>> y = adaptive_max_pool1d(x, output_size=4)
>>> y.shape
(2, 8, 4)