mindspore.ops.pixel_shuffle

mindspore.ops.pixel_shuffle(input, upscale_factor)[source]

Applies the PixelShuffle operation over input input which implements sub-pixel convolutions with stride \(1/r\) . 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 \times r^2, H, W)\) , and the output is of shape \((*, C, H \times r, W \times r)\), where r is an upscale factor and * is zero or more batch dimensions.

Parameters
  • input (Tensor) – Tensor of shape \((*, C \times r^2, H, W)\) . The dimension of input is larger than 2, and the length of third to last dimension can be divisible by upscale_factor squared.

  • upscale_factor (int) – factor to shuffle the input Tensor, and is a positive integer. upscale_factor is the above-mentioned \(r\).

Returns

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

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

  • ValueError – If the length of third to last dimension is not divisible by upscale_factor squared.

  • ValueError – If the dimension of input is less than 3.

  • TypeError – If input is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

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