fn

adaptive_max_pool3d

Tensor
adaptive_max_pool3d(x: Tensor, output_size: int | tuple[int, int, int], return_indices: bool = False)
source

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

xTensor
Input of shape (N, C, D, H, W).
output_sizeint or (int, int, int)
Desired output spatial shape.
return_indicesbool= False
Must currently be False.

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)