Skip to content
fn

adaptive_max_pool3d

→Tensor
adaptive_max_pool3d(input: Tensor, output_size: int | tuple[int | None, ...], return_indices: bool = False)

Implementing kernel

C++ engine symbols that back this Python API.

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

Volumetric analogue of adaptive_max_pool2d. Computes per-axis kernel and stride so the output spatial shape exactly matches output_size regardless of input shape.

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 output spatial shape.
return_indicesbool= False
Also return (output, indices): each output cell's maximum as a flat position in the input's spatial extent.

Returns

Tensor

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

Notes

The window for output cell (i,j,k)(i, j, k) is the 3-way product of axis-wise floor / ceil intervals (see adaptive_avg_pool2d for the 2-D version). The cell takes the maximum over that volume:

yn,c,d,h,w=max⁡(p,q,r)∈R(d,h,w)xn, c, p, q, ry_{n,c,d,h,w} = \max_{(p, q, r) \in R(d, h, w)} x_{n,\,c,\,p,\,q,\,r}

Examples

>>> import lucid
>>> from lucid.nn.functional import adaptive_max_pool3d
>>> x = lucid.randn(1, 8, 5, 7, 9)
>>> y = adaptive_max_pool3d(x, output_size=(1, 1, 1))
>>> y.shape
(1, 8, 1, 1, 1)

Used by 3