pytorch / 2 / generated / torch.nn.functional.pixel_shuffle.html

torch.nn.functional.pixel_shuffle

torch.nn.functional.pixel_shuffle(input, upscale_factor) → Tensor

Rearranges elements in a tensor of shape ( , C × r 2 , H , W ) (*, C \times r^2, H, W) to a tensor of shape ( , C , H × r , W × r ) (*, C, H \times r, W \times r) , where r is the upscale_factor.

See PixelShuffle for details.

Parameters
  • input (Tensor) – the input tensor
  • upscale_factor (int) – factor to increase spatial resolution by

Examples:

>>> input = torch.randn(1, 9, 4, 4)
>>> output = torch.nn.functional.pixel_shuffle(input, 3)
>>> print(output.size())
torch.Size([1, 1, 12, 12])

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.nn.functional.pixel_shuffle.html