Created
August 20, 2019 19:23
-
-
Save davidaknowles/6e95a643adaf3960d1648a6b369e9d0b to your computer and use it in GitHub Desktop.
torch currently only supports 2d pixel shuffle from https://arxiv.org/abs/1609.05158. This is the 1d version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pixel_shuffle_1d(x, upscale_factor): | |
batch_size, channels, steps = x.size() | |
channels //= upscale_factor | |
input_view = x.contiguous().view(batch_size, channels, upscale_factor, steps) | |
shuffle_out = input_view.permute(0, 1, 3, 2).contiguous() | |
return shuffle_out.view(batch_size, channels, steps * upscale_factor) |
Thanks for noticing the bug in the PR implementation! Would probably have just used that code otherwise.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this version works ok