快捷方式

PixelShuffle

class torch.nn.PixelShuffle(upscale_factor)[source][source]

根据上采样因子重新排列张量中的元素。

将形状为 (,C×r2,H,W)(*, C \times r^2, H, W) 的张量元素重新排列成形状为 (,C,H×r,W×r)(*, C, H \times r, W \times r) 的张量,其中 r 是上采样因子。

这对于实现步长为 1/r1/r 的高效亚像素卷积很有用。

更多详细信息请参阅论文:Shi 等人(2016)的 Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network

参数

upscale_factor (int) – 增加空间分辨率的因子

形状
  • 输入:(,Cin,Hin,Win)(*, C_{in}, H_{in}, W_{in}),其中 * 表示零个或多个批量维度

  • 输出:(,Cout,Hout,Wout)(*, C_{out}, H_{out}, W_{out}),其中

Cout=Cin÷upscale_factor2C_{out} = C_{in} \div \text{upscale\_factor}^2
Hout=Hin×upscale_factorH_{out} = H_{in} \times \text{upscale\_factor}
Wout=Win×upscale_factorW_{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])

文档

查阅 PyTorch 的完整开发者文档

查看文档

教程

获取针对初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并解答您的疑问

查看资源