class
FractionalMaxPool3d
extends
ModuleFractionalMaxPool3d(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)Applies fractional max-pooling over a 3-D volumetric feature map.
Extends FractionalMaxPool2d to three spatial dimensions
(depth, height, width) following the same random fractional boundary
scheme of Graham (2014). Independent random partitions are sampled
for each of the three axes:
Parameters
kernel_ sizeint or tuple[int, int, int]Size of the max pooling window at each sampled position.
output_ sizeint or tuple[int, int, int] or None= NoneFixed target output size
(D_out, H_out, W_out). Exactly one
of output_size and output_ratio must be given.output_ ratiofloat or tuple[float, float, float] or None= NoneTarget size as a fraction of each input dimension. Values must
lie in .
return_ indicesbool= FalseIf
True, also return flat indices of the selected maxima.
Default: False.Attributes
kernel_ sizeint or tuple[int, int, int]output_ sizeint or tuple[int, int, int] or Noneoutput_ ratiofloat or tuple[float, float, float] or Nonereturn_ indicesboolNotes
- Input:
(N, C, D_in, H_in, W_in) - Output:
(N, C, D_out, H_out, W_out)
- The random partition is drawn independently per batch-channel pair,
so the output shape is deterministic (fixed by
output_sizeoroutput_ratio) but the selected voxels differ across calls during training. - The stochastic sampling implicitly augments the data, which can reduce over-fitting on volumetric datasets.
- Delegates to
lucid.nn.functional.pooling.fractional_max_pool3d.
Examples
Volumetric fractional pooling with fixed output:
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.FractionalMaxPool3d(kernel_size=2, output_size=(4, 4, 4))
>>> x = lucid.ones((1, 32, 8, 8, 8))
>>> y = pool(x)
>>> y.shape
(1, 32, 4, 4, 4)
Using output_ratio for proportional downsampling:
>>> pool = nn.FractionalMaxPool3d(kernel_size=2, output_ratio=0.5)
>>> x = lucid.ones((2, 16, 12, 12, 12))
>>> y = pool(x)
>>> y.shape[0], y.shape[1]
(2, 16)Used by 1
Constructors
1dunder
__init__
→None__init__(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)Initialise the FractionalMaxPool3d module. See the class docstring for parameter semantics.