Table of Contents
Shortcuts

# PixelUnshuffle

class torch.nn.PixelUnshuffle(downscale_factor)

  Reverses the `PixelShuffle` operation by rearranging elements in a tensor of shape (∗,C,H×r,W×r)(*, C, H \times r, W \times r)(∗,C,H×r,W×r) to a tensor of shape (∗,C×r 2,H,W)(*, C \times r^2, H, W)(∗,C×r 2,H,W), where r is a downscale factor.

  See the paper: Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network by Shi et. al (2016) for more details.

  Parameters:

    downscale_factor (int) – factor to decrease spatial resolution by

  Shape:

    - Input: (∗,C i n,H i n,W i n)(*, C_{in}, H_{in}, W_{in})(∗,C in​,H in​,W in​), where * is zero or more batch dimensions

    - Output: (∗,C o u t,H o u t,W o u t)(*, C_{out}, H_{out}, W_{out})(∗,C o u t​,H o u t​,W o u t​), where

  C o u t=C i n×downscale_factor 2 C_{out} = C_{in} \times \text{downscale\_factor}^2 C o u t​=C in​×downscale_factor 2
  H o u t=H i n÷downscale_factor H_{out} = H_{in} \div \text{downscale\_factor} H o u t​=H in​÷downscale_factor
  W o u t=W i n÷downscale_factor W_{out} = W_{in} \div \text{downscale\_factor} W o u t​=W in​÷downscale_factor

  Examples:

      >>> 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])

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.