PixelShuffle¶
- class torch.nn.PixelShuffle(upscale_factor)[原始碼][原始碼]¶
根據放大因子重新排列 tensor 中的元素。
將形狀為 的張量重新排列成形狀為 的張量,其中 r 是放大因子。
這對於實現步幅為 的高效子像素卷積很有用。
更多詳細信息,請參閱論文:Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network,作者為 Shi 等人 (2016)。
- 參數
upscale_factor (int) – 空間解析度放大的倍數
- 形狀
輸入:,其中 * 是零或多個批次維度
輸出:,其中
輸出通道數 = 輸入通道數 ÷ (放大比例)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])