class paddle.nn. AvgPool3D ( kernel_size, stride=None, padding=0, ceil_mode=False, exclusive=True, divisor_override=None, data_format='NCDHW', name=None ) [source]

This operation applies 3D max pooling over input features based on the input, and kernel_size, stride, padding parameters. Input(X) and Output(Out) are in NCDHW format, where N is batch size, C is the number of channels, H is the height of the feature, D is the depth of the feature, and W is the width of the feature.

  • kernel_size (int|list|tuple) – The pool kernel size. If pool kernel size is a tuple or list, it must contain three integers, (kernel_size_Depth, kernel_size_Height, kernel_size_Width). Otherwise, the pool kernel size will be the cube of an int.

  • stride (int|list|tuple, optional) – The pool stride size. If pool stride size is a tuple or list, it must contain three integers, [stride_Depth, stride_Height, stride_Width). Otherwise, the pool stride size will be a cube of an int. Default None, then stride will be equal to the kernel_size.

  • padding (str|int|list|tuple, optional) – The padding size. Padding could be in one of the following forms. 1. A string in [‘valid’, ‘same’]. 2. An int, which means the feature map is zero padded by size of padding on every sides. 3. A list[int] or tuple(int) whose length is 3, [pad_depth, pad_height, pad_weight] whose value means the padding size of each dimension. 4. A list[int] or tuple(int) whose length is 6. [pad_depth_front, pad_depth_back, pad_height_top, pad_height_bottom, pad_width_left, pad_width_right] whose value means the padding size of each side. 5. A list or tuple of pairs of integers. It has the form [[pad_before, pad_after], [pad_before, pad_after], …]. Note that, the batch dimension and channel dimension should be [0,0] or (0,0). The default value is 0.

  • ceil_mode (bool, optional) – ${ceil_mode_comment}

  • exclusive (bool, optional) – Whether to exclude padding points in average pooling mode, default is True.

  • divisor_override (int|float, optional) – if specified, it will be used as divisor, otherwise kernel_size will be used. Default None.

  • data_format (str, optional) – The data format of the input and output data. An optional string from: “NCDHW”, “NDHWC”. The default is “NCDHW”. When it is “NCDHW”, the data is stored in the order of: [batch_size, input_channels, input_depth, input_height, input_width].

  • name (str, optional) – For detailed information, please refer to Name. Usually name is no need to set and None by default.


A callable object of AvgPool3D.

  • x(Tensor): The input tensor of avg pool3d operator, which is a 5-D tensor. The data type can be float32, float64.

  • output(Tensor): The output tensor of avg pool3d operator, which is a 5-D tensor. The data type is same as input x.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/nn/layer/pooling.py:docstring of paddle.nn.layer.pooling.AvgPool3D, line 47)

Definition list ends without a blank line; unexpected unindent.


import paddle
import paddle.nn as nn

# avg pool3d
input = paddle.uniform([1, 2, 3, 32, 32], dtype="float32", min=-1, max=1)
AvgPool3D = nn.AvgPool3D(kernel_size=2,
                       stride=2, padding=0)
output = AvgPool3D(input)
# output.shape [1, 2, 3, 16, 16]
forward ( x )


Defines the computation performed at every call. Should be overridden by all subclasses.

  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

extra_repr ( )


Extra representation of this layer, you can have custom implementation of your own layer.