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,Din,Hin,Win), the output is of shape (N,C,Dout,Hout,Wout), the operation is as follows.

Dout=(Din1)×strides[0]2×pads[0]+ksize[0]Hout=(Hin1)×strides[1]2×pads[1]+ksize[1]Wout=(Win1)×strides[2]2×pads[2]+ksize[2]

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,Doutstrides[0],Houtstrides[1],Woutstrides[2]),(N,C,Dout+strides[0],Hout+strides[1],Wout+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,Din,Hin,Win) or (N,Din,Hin,Win,C).

  • argmax (Tensor) - Max values' index. Tensor that has the same shape as x. Values of argmax must be in range [0,Din×Hin×Win1]. Data type must be int32 or int64.

Outputs:

Tensor, with shape (N,C,Dout,Hout,Wout) or (N,Dout,Hout,Wout,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.]]]]]