class
MaxPool3d
extends
ModuleMaxPool3d(kernel_size: _Size3d, stride: _Size3d | None = None, padding: _Size3d = 0, dilation: _Size3d = 1, return_indices: bool = False, ceil_mode: bool = False)Applies 3-D max pooling over a volumetric feature map.
Extends MaxPool2d to three spatial dimensions (depth, height,
width). For each output position the maximum is taken over a
window:
Output dimensions:
Parameters
kernel_sizeint or tuple[int, int, int]Size of the pooling window along
(D, H, W).strideint or tuple[int, int, int] or None= NoneStep between windows. Defaults to
kernel_size.paddingint or tuple[int, int, int]= 0Zero-padding applied to all six faces of the input.
Default:
0.dilationint or tuple[int, int, int]= 1Spacing between kernel elements. Default:
1.return_indicesbool= FalseNot yet supported. Default:
False.ceil_modebool= FalseUse ceiling for output size. Default:
False.Attributes
kernel_sizeint or tuple[int, int, int]strideint or tuple[int, int, int] or Nonepaddingint or tuple[int, int, int]dilationint or tuple[int, int, int]ceil_modeboolNotes
- Input:
(N, C, D_in, H_in, W_in) - Output:
(N, C, D_out, H_out, W_out)
- Typical use cases include video understanding (D = temporal frames) and 3-D medical imaging (CT / MRI volumes).
- Computational cost is proportional to the product .
Examples
Halving all three spatial dimensions:
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.MaxPool3d(kernel_size=2, stride=2)
>>> x = lucid.ones((1, 32, 16, 16, 16))
>>> y = pool(x)
>>> y.shape
(1, 32, 8, 8, 8)
Asymmetric window for video (different temporal/spatial strides):
>>> pool = nn.MaxPool3d(kernel_size=(1, 3, 3), stride=(1, 2, 2))
>>> x = lucid.ones((2, 64, 8, 28, 28))
>>> y = pool(x)
>>> y.shape
(2, 64, 8, 13, 13)Methods (3)
dunder
__init__
→None__init__(kernel_size: _Size3d, stride: _Size3d | None = None, padding: _Size3d = 0, dilation: _Size3d = 1, return_indices: bool = False, ceil_mode: bool = False)Initialise the MaxPool3d 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.