Last active
March 15, 2016 06:22
-
-
Save aman-tiwari/6bdb29f6cdeb680f0306 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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