What it does
Pixel shuffle takes a low-resolution tensor with r² times as many channels as needed and moves each group of r² channels into an r × r patch of neighboring output pixels. The preceding convolution therefore computes all the sub-pixel values at low resolution, which is cheap, and the shuffle only rearranges memory. Super-resolution networks such as ESPCN end with this rearrangement; the ESPCN export in WeightSpace spells it as Reshape, Transpose and Reshape rather than a single DepthToSpace. SpaceToDepth performs the reverse, folding pixel blocks into channels to downsample without losing information.
Formula
Y[n, c, r·y + i, r·x + j] = X[n, c·r2 + i·r + j, y, x] (CRD order)Shapes and parameters
- Shapes
- Input [N, C·r², H, W]; output [N, C, r·H, r·W].
- Parameters
- None. The learned work happens in the convolution before it.
- Used for
- ESPCN and other super-resolution models, some frame interpolation and detection necks.
In WeightSpace
Read-only itself. In the ESPCN super-resolution model the editable value is a shared offset on the nine biases of the convolution that feeds the sub-pixel rearrangement, one per position in each 3 × 3 block, so an edit brightens or darkens every output pixel.