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

This API implements max unpooling 1d operation.

max_unpool1d accepts the output of max_pool1d 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, L_{in})\)

  • Output: \((N, C, L_{out})\), where

\[L_{out} = (L_{in} - 1) * stride - 2 * padding + kernel\_size\]

or as given by output_size in the call operator.

  • 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 “NCL”. When it is “NCL”, the data is stored in the order of: [batch_size, input_channels, input_length].

  • 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 MaxUnPool1D.


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

>>> data = paddle.rand(shape=[1, 3, 16])
>>> pool_out, indices = F.max_pool1d(data, kernel_size=2, stride=2, padding=0, return_mask=True)
>>> print(pool_out.shape)
[1, 3, 8]
>>> print(indices.shape)
[1, 3, 8]
>>> Unpool1D = paddle.nn.MaxUnPool1D(kernel_size=2, padding=0)
>>> unpool_out = Unpool1D(pool_out, indices)
>>> print(unpool_out.shape)
[1, 3, 16]
forward ( x, indices )


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.