PixelShuffle¶
- class PixelShuffle(upscale_factor, **kwargs)[源代码]¶
将形状为(, C x r^2, H, W)的向量中的元素重新排列为形状为(, C, H x r, W x r) 的向量,其中 r 是一个上采样因子,其中*是零或 batch 的维度。
See the paper: Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network<https://arxiv.org/abs/1609.05158> for more details.
- 参数
upscale_factor (
int
) – factor to increase spatial resolution by.
- Shape:
input: \((*, C_{in}, H_{in}, W_{in})\), where * is zero or more batch dimensions.
output: \((*, C_{out}, H_{out}, W_{out})\), where:
\[\]- begin{aligned}
C_{out} = C_{in} div text{upscale_factor}^2 \ H_{out} = H_{in} times text{upscale_factor} \ W_{out} = W_{in} times text{upscale_factor} \
end{aligned}
实际案例
>>> import numpy as np >>> pixel_shuffle = M.PixelShuffle(3) >>> input = mge.tensor(np.random.randn(1, 9, 4, 4)) >>> output = pixel_shuffle(input) >>> output.numpy().shape (1, 1, 12, 12)