max_unpool3d

paddle.nn.functional. max_unpool3d ( x, indices, kernel_size, stride=None, padding=0, data_format='NCDHW', output_size=None, name=None ) [source]

This API implements max unpooling 3d opereation. max_unpool3d accepts the output of max_pool3d as input, including the indices of the maximum value and calculate the partial inverse. All non-maximum values are set to zero.

  • Input: \((N, C, D_{in}, H_{in}, W_{in})\)

  • Output: \((N, C, D_{out}, H_{out}, W_{out})\), where

\[D_{out} = (D_{in} - 1) * stride[0] - 2 * padding[0] + kernel\_size[0]\]
\[H_{out} = (H_{in} - 1) * stride[1] - 2 * padding[1] + kernel\_size[1]\]
\[W_{out} = (W_{in} - 1) * stride[2] - 2 * padding[2] + kernel\_size[2]\]

or as given by output_size in the call operator

Parameters
  • x (Tensor) – The input tensor of unpooling operator which is a 5-D tensor with shape [N, C, D, H, W]. The format of input tensor is “NCDHW”, where N is batch size, C is the number of channels, D is the depth of the feature, H is the height of the feature, and W is the width of the feature. The data type is float32 or float64.

  • indices (Tensor) – The indices given out by maxpooling3d which is a 5-D tensor with shape [N, C, D, H, W]. The format of input tensor is “NCDHW” , where N is batch size, C is the number of channels, D is the depth of the feature, H is the height of the feature, and W is the width of the feature. The data type is float32 or float64.

  • kernel_size (int|list|tuple) – The unpool kernel size. If unpool kernel size is a tuple or list, it must contain an integer.

  • stride (int|list|tuple) – The unpool stride size. If unpool stride size is a tuple or list, it must contain an integer.

  • padding (int | tuple) – Padding that was added to the input.

  • output_size (list|tuple, optional) – The target output size. If output_size is not specified, the actual output shape will be automatically calculated by (input_shape, kernel_size, stride, padding).

  • data_format (string) – The data format of the input and output data. 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.

Returns

The output tensor of unpooling result.

Return type

Tensor

Examples

>>> import paddle
>>> import paddle.nn.functional as F

>>> data = paddle.rand(shape=[1, 1, 4, 4, 6])
>>> pool_out, indices = F.max_pool3d(data, kernel_size=2, stride=2, padding=0, return_mask=True)
>>> print(pool_out.shape)
[1, 1, 2, 2, 3]
>>> print(indices.shape)
[1, 1, 2, 2, 3]
>>> unpool_out = F.max_unpool3d(pool_out, indices, kernel_size=2, padding=0)
>>> print(unpool_out.shape)
[1, 1, 4, 4, 6]