Skip to content

Instantly share code, notes, and snippets.

@thouis
Created November 15, 2016 17:23
Show Gist options
  • Save thouis/7f9a166c1a0bf10453159f2c05f50c08 to your computer and use it in GitHub Desktop.
Save thouis/7f9a166c1a0bf10453159f2c05f50c08 to your computer and use it in GitHub Desktop.
def depth_to_space(x, blocksize=2):
b, k, d, r, c = x.shape
r1 = x.reshape((b, k // (blocksize ** 2), blocksize, blocksize, d, r, c))
r2 = r1.transpose(0, 1, 4, 5, 2, 6, 3)
return r2.reshape((b, k // (blocksize ** 2), d, r * blocksize, c * blocksize))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment