MaxUnPool2D

class paddle.nn. MaxUnPool2D ( kernel_size, stride=None, padding=0, data_format='NCHW', output_size=None, name=None ) [source]

This API implements max unpooling 2d operation.

‘max_unpool2d’ accepts the output of ‘max_unpool2d’ as input Including the indices of the maximum value and calculating the partial inverse All non-maximum values are set to zero.

Parameters
  • kernel_size (int|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.

  • kernel_size – Size of the max unpooling window.

  • 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, padding).

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

  • Input (-) – \((N, C, H_{in}, W_{in})\)

  • Output (-) –

    \((N, C, H_{out}, W_{out})\), where

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

    or as given by output_size in the call operator

Returns

A callable object of MaxUnPool2D.

Examples

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

>>> data = paddle.rand(shape=[1, 1, 6, 6])
>>> pool_out, indices = F.max_pool2d(data, kernel_size=2, stride=2, padding=0, return_mask=True)
>>> print(pool_out.shape)
[1, 1, 3, 3]
>>> print(indices.shape)
[1, 1, 3, 3]
>>> Unpool2D = paddle.nn.MaxUnPool2D(kernel_size=2, padding=0)
>>> unpool_out = Unpool2D(pool_out, indices)
>>> print(unpool_out.shape)
[1, 1, 6, 6]
forward ( x, indices )

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.