mindscience.common.pixel_shuffle
- mindscience.common.pixel_shuffle(x, upscale_factor)[source]
Applies a pixel_shuffle operation over an input signal composed of several input planes. This is useful for implementiong efficient sub-pixel convolution with a stride of \(1/r\). For more details, refer to Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network .
Typically, the x is of shape \((*, C \times r^2, H, W)\) , and the output is of shape \((*, C, H \times r, W \times r)\), where r is an upscale factor and * is zero or more batch dimensions.
- Parameters
x (Tensor) – Tensor of shape \((*, C \times r^2, H, W)\) . The dimension of x is larger than
2, and the length of third to last dimension can be divisible by upscale_factor squared.upscale_factor (int) – Factor to increase spatial resolution by, and is a positive integer.
- Returns
Tensor, tensor of shape \((*, C, H \times r, W \times r)\) .
- Raises
ValueError – If upscale_factor is not a positive integer.
ValueError – If the length of third to last dimension is not divisible by upscale_factor squared.
TypeError – If the dimension of x is less than
3.