mindspore.ops.pixel_unshuffle

mindspore.ops.pixel_unshuffle(x, downscale_factor)[source]

Applies a pixel_unshuffle operation over an input signal composed of several input planes. For more details, refer to Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network .

Typically, the input is of shape \((*, C, H \times r, W \times r)\) , and the output is of shape \((*, C \times r^2, H, W)\) , where r is a downscale factor and * is zero or more batch dimensions.

Parameters
  • x (Tensor) – Tensor of shape \((*, C, H \times r, W \times r)\) . The dimension of x is larger than 2, and the length of second to last dimension or last dimension can be divisible by downscale_factor .

  • downscale_factor (int) – factor to decrease spatial resolution by, and is a positive integer.

Returns

  • output (Tensor) - Tensor of shape \((*, C \times r^2, H, W)\) .

Raises
  • ValueError – If downscale_factor is not a positive integer.

  • ValueError – If the length of second to last dimension or last dimension is not divisible by downscale_factor .

  • TypeError – If the dimension of x is less than 3.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = np.arange(12 * 12).reshape((1, 1, 12, 12))
>>> input_x = mindspore.Tensor(input_x, mindspore.dtype.int32)
>>> output = ops.pixel_unshuffle(input_x, 3)
>>> print(output.shape)
(1, 9, 4, 4)