Skip to content

Instantly share code, notes, and snippets.

@aman-tiwari
Last active March 15, 2016 06:22
Show Gist options
  • Save aman-tiwari/6bdb29f6cdeb680f0306 to your computer and use it in GitHub Desktop.
Save aman-tiwari/6bdb29f6cdeb680f0306 to your computer and use it in GitHub Desktop.
def unpool(x, repeat=False):
s = x.shape
if repeat:
r = 1
else:
r = 0
kernel_x = np.tile([1, r] + [0,0] * (s[1]), s[1])[:s[1]*s[1]*2].reshape(s[1], (s[1]*2))
kernel_y = np.tile([1, r] + [0,0] * (s[0]), s[0])[:s[0]*s[0]*2].reshape(s[0], s[0]*2)
return np.matmul(np.matmul(x, kernel_x).transpose(), kernel_y).transpose()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment