class
AdaptiveMaxPool3d
extends
ModuleAdaptiveMaxPool3d(output_size: _Size3d, return_indices: bool = False)Applies adaptive 3-D max pooling to produce a fixed output volume.
Extends AdaptiveMaxPool2d by one depth dimension. For each
output voxel the maximum is taken over the
adaptively-sized 3-D window:
where the window bounds follow the same ratio formula as
AdaptiveAvgPool3d.
Parameters
output_sizeint or tuple[int, int, int]Target
(D_out, H_out, W_out). A scalar is broadcast.return_indicesbool= FalseNot yet supported. Default:
False.Attributes
output_sizeint or tuple[int, int, int]Notes
- Input:
(N, C, D_in, H_in, W_in) - Output:
(N, C, D_out, H_out, W_out)
- 3-D adaptive max pooling is useful for video classification models that must handle clips of arbitrary duration.
- Like all adaptive pooling layers, the variable-sized windows can produce slightly different effective receptive fields per output cell when the input is not evenly divisible.
Examples
Compress volumetric feature map to ``2 × 2 × 2``:
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.AdaptiveMaxPool3d(output_size=2)
>>> x = lucid.ones((1, 32, 8, 8, 8))
>>> y = pool(x)
>>> y.shape
(1, 32, 2, 2, 2)
Mixed output sizes (keep depth, compress spatial):
>>> pool = nn.AdaptiveMaxPool3d(output_size=(8, 1, 1))
>>> x = lucid.ones((2, 64, 8, 14, 14))
>>> y = pool(x)
>>> y.shape
(2, 64, 8, 1, 1)Methods (3)
dunder
__init__
→None__init__(output_size: _Size3d, return_indices: bool = False)Initialise the AdaptiveMaxPool3d module. See the class docstring for parameter semantics.
fn
forward
→Tensorforward(x: Tensor)Apply the pooling operation to the input tensor.
Parameters
inputTensorInput tensor of shape where are the
spatial dimensions appropriate for this pooling layer.
Returns
TensorPooled output tensor.
fn
extra_repr
→strextra_repr()Return a string representation of the layer's configuration.