mindspore.nn.PixelUnshuffle
- class mindspore.nn.PixelUnshuffle(downscale_factor)[源代码]
- 对 input 应用逆像素重组操作,这是像素重组的逆操作。关于PixelUnshuffle算法详细介绍,请参考 Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network 。 - 通常情况下,输入shape \((*, C, H \times r, W \times r)\) ,输出shape \((*, C \times r^2, H, W)\) 。 \(r\) 是缩小因子。 \(*\) 是大于等于0的维度。 - 参数:
- downscale_factor (int) - 恢复输入Tensor的因子,是正整数。 downscale_factor 是上面提到的 \(r\) 。 
 
- 输入:
- input (Tensor) - Tensor,shape为 \((*, C, H \times r, W \times r)\) 。输入Tensor的维度需要大于2,并且倒数第一和倒数第二维对应的值可以被 downscale_factor 整除。 
 
- 输出:
- output (Tensor) - Tensor,shape为 \((*, C \times r^2, H, W)\) 。 
 
- 异常:
- ValueError - downscale_factor 不是正整数。 
- ValueError - 输入 input 倒数第一和倒数第二维度对应的值不能被 downscale_factor 整除。 
- ValueError - input 维度小于3。 
- TypeError - input 不是Tensor。 
 
- 支持平台:
- Ascend- GPU- CPU
 - 样例: - >>> import mindspore as ms >>> import numpy as np >>> pixel_unshuffle = ms.nn.PixelUnshuffle(2) >>> input_x = np.arange(8 * 8).reshape((1, 1, 8, 8)) >>> input_x = ms.Tensor(input_x, ms.dtype.int32) >>> output = pixel_unshuffle(input_x) >>> print(output.shape) (1, 4, 4, 4)