mindspore.ops.MaxUnpool3D

View Source On Gitee
class mindspore.ops.MaxUnpool3D(ksize, strides=0, pads=0, output_shape=(), data_format='NCDHW')[source]

Computes the inverse of mindspore.ops.MaxPool3D.

MaxUnpool3D keeps the maximal value and set all position of non-maximal values to zero. Typically the input is of shape \((N, C, D_{in}, H_{in}, W_{in})\), the output is of shape \((N, C, D_{out}, H_{out}, W_{out})\), the operation is as follows.

\[\begin{split}\begin{array}{ll} \\ D_{out} = (D{in} - 1) \times strides[0] - 2 \times pads[0] + ksize[0] \\ H_{out} = (H{in} - 1) \times strides[1] - 2 \times pads[1] + ksize[1] \\ W_{out} = (W{in} - 1) \times strides[2] - 2 \times pads[2] + ksize[2] \\ \end{array}\end{split}\]

Warning

This is an experimental API that is subject to change or deletion.

Parameters
  • ksize (Union[int, tuple[int]]) – The size of kernel used to take the maximum value, is an int number that represents depth, height and width of the kernel, or a tuple of three int numbers that represent depth, height and width respectively.

  • strides (Union[int, tuple[int]], optional) –

    The distance of kernel moving. Default: 0 .

    • If it is an int number, the depth, height and width of movement are all equal to strides.

    • If it is a tuple of three int numbers, they represent depth, height and width of movement respectively.

    • If strides is 0 or (0, 0, 0), then strides equal to ksize.

  • pads (Union[int, tuple[int]], optional) –

    The pad value to be filled. Default: 0 .

    • If pads is an integer, the paddings of depth, height and width are the same, equal to pads.

    • If pads is a tuple of three integers, the padding of depth, height and width equal to pads[0], pads[1] and pads[2] correspondingly.

  • output_shape (tuple[int], optional) – The target output size. Default: () . If \(output\_shape == ()\), then the shape of output computed by kszie, strides and pads shown above. If \(output\_shape != ()\), then output_shape format must be \((N, C, D, H, W)\) or \((N, D, H, W, C)\) and output_shape must be in range \([(N, C, D_{out} - strides[0], H_{out} - strides[1], W_{out} - strides[2]), (N, C, D_{out} + strides[0], H_{out} + strides[1], W_{out} + strides[2])]\).

  • data_format (str, optional) – The optional value for data format. Currently support 'NCDHW' and 'NDHWC' . Default: 'NCDHW' .

Inputs:
  • x (Tensor) - The input Tensor to invert. Tensor of shape \((N, C, D_{in}, H_{in}, W_{in})\) or \((N, D_{in}, H_{in}, W_{in}, C)\).

  • argmax (Tensor) - Max values’ index. Tensor that has the same shape as x. Values of argmax must be in range \([0, D_{in} \times H_{in} \times W_{in} - 1]\). Data type must be int32 or int64.

Outputs:

Tensor, with shape \((N, C, D_{out}, H_{out}, W_{out})\) or \((N, D_{out}, H_{out}, W_{out}, C)\). Has the same data type with x.

Raises
  • TypeError – If data type of x or argmax is Number.

  • TypeError – If ksize, strides or pads is neither int nor tuple.

  • ValueError – If numbers in strides or ksize is negative.

  • ValueError – If numbers in pads is negative.

  • ValueError – If ksize, strides or pads is a tuple whose length is not equal to 3.

  • ValueError – If data_format is not a str or is neither NCDHW nor NDHWC.

  • ValueError – If output_shape whose length is neither 0 or 5.

  • ValueError – If output_shape is not close to output size range computed by attr ksize, strides, pads.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([[[[[0, 1], [8, 9]]]]]).astype(np.float32))
>>> argmax = Tensor(np.array([[[[[0, 1], [2, 3]]]]]).astype(np.int64))
>>> maxunpool3d = ops.MaxUnpool3D(ksize=1, strides=1, pads=0)
>>> output = maxunpool3d(x, argmax)
>>> print(output.asnumpy())
[[[[[0. 1.]
    [8. 9.]]]]]