fn

fractional_max_pool3d

Tensor or (Tensor, Tensor)
fractional_max_pool3d(x: Tensor, kernel_size: int | tuple[int, int, int], output_size: int | tuple[int, int, int] | None = None, output_ratio: float | tuple[float, float, float] | None = None, return_indices: bool = False, _random_samples: Tensor | None = None)
source

Fractional max-pooling over a 3-D input (Graham, 2014).

Volumetric extension of fractional_max_pool2d. Provides non-integer effective stride along all three spatial axes — a structural regulariser for 3-D CNNs.

Parameters

xTensor
Input of shape (N, C, D, H, W).
kernel_sizeint or (int, int, int)
Size of the pooling window per axis.
output_sizeint or (int, int, int)= None
Exact desired output spatial shape. Mutually exclusive with output_ratio.
output_ratiofloat or (float, float, float)= None
Multiplicative shrinkage per axis. Mutually exclusive with output_size.
return_indicesbool= False
When True, also return per-output-cell argmax positions (flattened D × H × W index).
_random_samplesTensor= None
Per-instance uniform samples of shape (N, C, 3). Defaults to fresh lucid.rand.

Returns

Tensor or (Tensor, Tensor)

Output of shape (N, C, oD, oH, oW); when return_indices, also the argmax indices.

Notes

Each axis runs Graham's start-position formula independently (see fractional_max_pool2d Notes). Implementation is a pure-Python composite; gradients flow through Tensor.max.

Examples

>>> import lucid
>>> from lucid.nn.functional import fractional_max_pool3d
>>> x = lucid.randn(1, 2, 8, 8, 8)
>>> y = fractional_max_pool3d(x, kernel_size=2, output_ratio=0.5)
>>> y.shape
(1, 2, 4, 4, 4)