Applies adaptive 3-D average pooling to produce a fixed output volume.
Automatically derives window parameters so that the output has the
specified (D_out, H_out, W_out) shape regardless of input size.
For output voxel :
where the boundary indices follow the same ratio formula as in
AdaptiveAvgPool2d, applied independently per dimension.
Parameters
output_sizeint or tuple[int, int, int]Target
(D_out, H_out, W_out). A scalar is broadcast to all
three dimensions.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)
- Pass
output_size=(1, 1, 1)for 3-D global average pooling, which collapses a volumetric feature map to a single vector per channel — the standard head for 3-D classification networks. - Window sizes are determined per output cell and may differ, but all cells together partition the input without overlap or gap.
Examples
3-D global average pooling:
>>> import lucid
>>> import lucid.nn as nn
>>> gap = nn.AdaptiveAvgPool3d(output_size=1)
>>> x = lucid.ones((2, 256, 4, 7, 7))
>>> y = gap(x)
>>> y.shape
(2, 256, 1, 1, 1)
Fixed spatial output with variable input:
>>> pool = nn.AdaptiveAvgPool3d(output_size=(2, 4, 4))
>>> for d in [4, 8, 16]:
... x = lucid.ones((1, 64, d, 28, 28))
... assert pool(x).shape == (1, 64, 2, 4, 4)Used by 1
Constructors
1Instance methods
2Return a string representation of the layer's configuration.