fn
avg_pool1d
→Tensoravg_pool1d(x: Tensor, kernel_size: int | tuple[int, ...], stride: int | tuple[int, ...] | None = None, padding: int | tuple[int, ...] = 0, ceil_mode: bool = False, count_include_pad: bool = True)1-D average pooling over a sliding window.
Replaces each window with its arithmetic mean. Smoother than max-pool and used wherever maintaining the overall response magnitude matters (e.g. before a fully connected classifier head).
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.
ceil_modebool= FalseUse ceil instead of floor in the output-size formula.
count_include_padbool= TrueWhen
True, padding cells contribute to the denominator.Returns
TensorOutput of shape (N, C, L_out) where
Notes
Math (averaging window of cardinality ):
Unlike max-pool, average-pool is fully differentiable everywhere, so the gradient is uniformly distributed back across all window positions.
Examples
>>> import lucid
>>> from lucid.nn.functional import avg_pool1d
>>> x = lucid.randn(2, 3, 20)
>>> y = avg_pool1d(x, kernel_size=4, stride=2)
>>> y.shape
(2, 3, 9)