Skip to content
fn

adaptive_avg_pool3d

→Tensor
adaptive_avg_pool3d(input: Tensor, output_size: int | tuple[int | None, ...])

Implementing kernel

C++ engine symbols that back this Python API.

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

inputTensor
Input of shape (N, C, D, H, W), or (C, D, H, W) unbatched.
output_sizeint or (int or None, int or None, int or None)
Desired (oD, oH, oW); a single int applies to all three axes.

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=1∣R∣∑(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)

Used by 3