You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pixel_shuffle.py 519 B

1234567891011121314151617
  1. from ..functional.nn import pixel_shuffle
  2. from .module import Module
  3. class PixelShuffle(Module):
  4. r"""
  5. Rearranges elements in a tensor of shape (*, C x r^2, H, W) to a tensor of
  6. shape (*, C, H x r, W x r), where r is an upscale factor, where * is zero
  7. or more batch dimensions.
  8. """
  9. def __init__(self, upscale_factor: int, **kwargs):
  10. super().__init__(**kwargs)
  11. self.upscale_factor = upscale_factor
  12. def forward(self, x):
  13. return pixel_shuffle(x, self.upscale_factor)