class
AvgPool3d
extends
ModuleAvgPool3d(kernel_size: _Size3d, stride: _Size3d | None = None, padding: _Size3d = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None)Applies 3-D average pooling over a volumetric feature map.
Computes the arithmetic mean of values in a sliding window:
where when count_include_pad=True.
Output dimensions mirror those of MaxPool3d.
Parameters
kernel_sizeint or tuple[int, int, int]Size of the averaging 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 on all six faces. Default:
0.ceil_modebool= FalseUse ceiling for output size. Default:
False.count_include_padbool= TrueInclude zero-padded elements in the denominator. Default:
True.divisor_overrideint or None= NoneIf set, use this value as the divisor instead of the window size.
(Stored but not yet applied in the current implementation.)
Default:
None.Attributes
kernel_sizeint or tuple[int, int, int]strideint or tuple[int, int, int] or Nonepaddingint or tuple[int, int, int]ceil_modeboolcount_include_padboolNotes
- Input:
(N, C, D_in, H_in, W_in) - Output:
(N, C, D_out, H_out, W_out)
- 3-D average pooling is the natural extension of 2-D GAP to video
and volumetric data; global 3-D average pooling collapses
(D, H, W)to(1, 1, 1)for a compact feature vector. - Gradients are distributed uniformly over all elements in a window, which can help maintain stable training compared to max pooling.
Examples
Reduce temporal resolution while keeping spatial size:
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.AvgPool3d(kernel_size=(2, 1, 1), stride=(2, 1, 1))
>>> x = lucid.ones((1, 16, 16, 8, 8))
>>> y = pool(x)
>>> y.shape
(1, 16, 8, 8, 8)
Halve all three dimensions simultaneously:
>>> pool = nn.AvgPool3d(kernel_size=2, stride=2)
>>> x = lucid.ones((2, 32, 8, 8, 8))
>>> y = pool(x)
>>> y.shape
(2, 32, 4, 4, 4)Methods (3)
dunder
__init__
→None__init__(kernel_size: _Size3d, stride: _Size3d | None = None, padding: _Size3d = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None)Initialise the AvgPool3d 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.