快速鍵

PixelShuffle

class torch.nn.PixelShuffle(upscale_factor)[原始碼][原始碼]

根據放大因子重新排列 tensor 中的元素。

將形狀為 (,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 的高效子像素卷積很有用。

更多詳細信息,請參閱論文:Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network,作者為 Shi 等人 (2016)。

參數

upscale_factor (int) – 空間解析度放大的倍數

形狀
  • 輸入:(,Cin,Hin,Win)(*, C_{in}, H_{in}, W_{in}),其中 * 是零或多個批次維度

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

輸出通道數 = 輸入通道數 ÷ (放大比例)2
輸出高度 = 輸入高度 × 放大比例
輸出寬度 = 輸入寬度 × 放大比例

範例

>>> 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 的完整開發者文件

檢視文件

教學課程

取得針對初學者和進階開發者的深入教學課程

檢視教學課程

資源

尋找開發資源並獲得問題解答

檢視資源