fn
adaptive_avg_pool1d
→Tensoradaptive_avg_pool1d(x: Tensor, output_size: int | tuple[int, ...])1-D adaptive average pooling — produces a fixed output length.
Computes kernel / stride dynamically so that the output's spatial
length equals output_size regardless of input length. Handy
when feeding variable-length sequences into a head expecting a
fixed embedding size.
Parameters
xTensorInput of shape
(N, C, L).output_sizeint or tuple of intDesired length of the output spatial axis.
Returns
TensorOutput of shape (N, C, output_size).
Notes
For each output index , the corresponding input window is
and the cell is the mean over that window. When L divides
evenly by L_out the operation reduces to plain
avg_pool1d with kernel == stride == L / L_out;
otherwise Lucid falls back to a per-slot Python-level computation
that still keeps all data on the original device.
Examples
>>> import lucid
>>> from lucid.nn.functional import adaptive_avg_pool1d
>>> x = lucid.randn(2, 32, 13)
>>> y = adaptive_avg_pool1d(x, output_size=5)
>>> y.shape
(2, 32, 5)