pixel_shuffle

paddle.nn.functional. pixel_shuffle ( x, upscale_factor, data_format='NCHW', name=None ) [source]

This API implements pixel shuffle operation. See more details in api_nn_vision_PixelShuffle . :param x: 4-D tensor, the data type should be float32 or float64. :type x: Tensor :param upscale_factor: factor to increase spatial resolution. :type upscale_factor: int :param data_format: The data format of the input and output data. An optional string from: “NCHW”, “NHWC”. The default is “NCHW”. When it is “NCHW”, the data is stored in the order of: [batch_size, input_channels, input_height, input_width]. :type data_format: str :param name: The default value is None. Normally there is no need for user to set this property. :type name: str, optional

Returns

Reshaped tensor according to the new dimension.

Return type

Out(tensor)

Raises

ValueError – If the square of upscale_factor cannot divide the channels of input.

Examples

import paddle
import paddle.nn.functional as F
import numpy as np
x = np.random.randn(2, 9, 4, 4).astype(np.float32)
x_var = paddle.to_tensor(x)
out_var = F.pixel_shuffle(x_var, 3)
out = out_var.numpy()
# (2, 1, 12, 12)