fn

adaptive_avg_pool3d

Tensor
adaptive_avg_pool3d(x: Tensor, output_size: int | tuple[int, int, int])
source

3-D adaptive average pooling — produces a fixed (D, H, W).

Volumetric counterpart of adaptive_avg_pool2d. Used by 3-D classification heads to collapse a volumetric feature map to a fixed embedding shape regardless of input size.

Parameters

xTensor
Input of shape (N, C, D, H, W).
output_sizeint or (int, int, int)
Desired output spatial shape.

Returns

Tensor

Output of shape (N, C, oD, oH, oW).

Notes

Per-cell window definitions follow the same floor / ceil construction used in the 2-D variant. The cell value is the mean over the volumetric window:

yn,c,d,h,w=1R(p,q,r)R(d,h,w)xn,c,p,q,ry_{n,c,d,h,w} = \frac{1}{|R|} \sum_{(p, q, r) \in R(d, h, w)} x_{n,\,c,\,p,\,q,\,r}

When the input dims divide output_size evenly the engine path is taken; otherwise a per-slot Python fallback runs (all data stays on-device).

Examples

>>> import lucid
>>> from lucid.nn.functional import adaptive_avg_pool3d
>>> x = lucid.randn(1, 16, 8, 10, 10)
>>> y = adaptive_avg_pool3d(x, output_size=(2, 2, 2))
>>> y.shape
(1, 16, 2, 2, 2)