PixelShuffle
- 类torch.nn.PixelShuffle(upscale_factor)[源代码]
-
根据放大的因素,重新排列张量中的元素。
将形状为 $(*, C \times r^2, H, W)$ 的张量元素重新排列为形状为 $(*, C, H \times r, W \times r)$ 的张量,其中 r 是上采样因子。
这有助于实现步长为$1/r$的高效子像素卷积。
参见 Shi 等人于 2016 年发表的论文《使用高效的子像素卷积神经网络进行实时单图像和视频超分辨率》(Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network),了解更多详细信息。
- 参数
-
upscale_factor (int) – 空间分辨率增加的因子
- 形状:
-
-
输入: $(*, C_{in}, H_{in}, W_{in})$,其中 * 代表零个或多个批次维度
-
输出为 $(*, C_{\text{out}}, H_{\text{out}}, W_{\text{out}})$,其中
-
$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}$示例:
>>> pixel_shuffle = nn.PixelShuffle(3) >>> input = torch.randn(1, 9, 4, 4) >>> output = pixel_shuffle(input) >>> print(output.size()) torch.Size([1, 1, 12, 12])