AdaptiveMaxPool3D

class paddle.nn. AdaptiveMaxPool3D ( output_size, return_mask=False, name=None ) [source]

This operation applies 3D adaptive max pooling on input tensor. The h and w dimensions of the output tensor are determined by the parameter output_size. The difference between adaptive pooling and pooling is adaptive one focus on the output size.

For adaptive max pool3d:

\[ \begin{align}\begin{aligned}dstart &= floor(i * D_{in} / D_{out})\\dend &= ceil((i + 1) * D_{in} / D_{out})\\hstart &= floor(j * H_{in} / H_{out})\\hend &= ceil((j + 1) * H_{in} / H_{out})\\wstart &= floor(k * W_{in} / W_{out})\\wend &= ceil((k + 1) * W_{in} / W_{out})\\Output(i ,j, k) &= max(Input[dstart:dend, hstart:hend, wstart:wend])\end{aligned}\end{align} \]
Parameters
  • output_size (int|list|tuple) – The pool kernel size. If pool kernel size is a tuple or list, it must contain three elements, (D, H, W). D, H and W can be either a int, or None which means the size will be the same as that of the input.

  • return_mask (bool, optional) – If true, the index of max pooling point will be returned along with outputs. Default False.

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

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

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

Returns

A callable object of AdaptiveMaxPool3D.

Examples

>>> # adaptive max pool3d
>>> # suppose input data in shape of [N, C, D, H, W], `output_size` is [l, m, n],
>>> # output shape is [N, C, l, m, n], adaptive pool divide D, H and W dimensions
>>> # of input data into l * m * n grids averagely and performs poolings in each
>>> # grid to get output.
>>> # adaptive max pool performs calculations as follow:
>>> #
>>> #     for i in range(l):
>>> #         for j in range(m):
>>> #             for k in range(n):
>>> #                 dstart = floor(i * D / l)
>>> #                 dend = ceil((i + 1) * D / l)
>>> #                 hstart = floor(j * H / m)
>>> #                 hend = ceil((j + 1) * H / m)
>>> #                 wstart = floor(k * W / n)
>>> #                 wend = ceil((k + 1) * W / n)
>>> #                 output[:, :, i, j, k] =
>>> #                     max(input[:, :, dstart:dend, hstart: hend, wstart: wend])
>>> import paddle

>>> x = paddle.rand([2, 3, 8, 32, 32])
>>> pool = paddle.nn.AdaptiveMaxPool3D(output_size=4)
>>> out = pool(x)
>>> print(out.shape)
[2, 3, 4, 4, 4]
>>> pool = paddle.nn.AdaptiveMaxPool3D(output_size=3, return_mask=True)
>>> out, indices = pool(x)
>>> print(out.shape)
[2, 3, 3, 3, 3]
>>> print(indices.shape)
[2, 3, 3, 3, 3]
forward ( x )

forward

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

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

extra_repr ( )

extra_repr

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