评价此页

PixelUnshuffle#

class torch.nn.PixelUnshuffle(downscale_factor)[源代码]#

PixelShuffle 操作的逆操作。

将形状为 (,C,H×r,W×r)(*, C, H \times r, W \times r) 的张量进行 PixelShuffle 操作的逆操作,将其重排为形状为 (,C×r2,H,W)(*, C \times r^2, H, W) 的张量,其中 r 是下采样因子。

更多细节请参阅论文:Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network,作者 Shi 等人(2016)。

参数

downscale_factor (int) – 用于减小空间分辨率的因子

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

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

Cout=Cin×downscale_factor2C_{out} = C_{in} \times \text{downscale\_factor}^2
Hout=Hin÷downscale_factorH_{out} = H_{in} \div \text{downscale\_factor}
Wout=Win÷downscale_factorW_{out} = W_{in} \div \text{downscale\_factor}

示例

>>> pixel_unshuffle = nn.PixelUnshuffle(3)
>>> input = torch.randn(1, 1, 12, 12)
>>> output = pixel_unshuffle(input)
>>> print(output.size())
torch.Size([1, 9, 4, 4])
extra_repr()[源代码]#

返回模块的额外表示。

返回类型

str

forward(input)[源代码]#

执行前向传播。

返回类型

张量