-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
identity hop shape fix #59
base: master
Are you sure you want to change the base?
Conversation
@@ -113,7 +113,7 @@ def residual_block(l, increase_dim=False, projection=False): | |||
block = NonlinearityLayer(ElemwiseSumLayer([stack_2, projection]),nonlinearity=rectify) | |||
else: | |||
# identity shortcut, as option A in paper | |||
identity = ExpressionLayer(l, lambda X: X[:, :, ::2, ::2], lambda s: (s[0], s[1], s[2]//2, s[3]//2)) | |||
identity = ExpressionLayer(l, lambda X: X[:, :, ::2, ::2], lambda s: (s[0], s[1], int(math.ceil(float(s[2])/2)), int(math.ceil(float(s[3])/2)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
math
was never imported, though. What about a simpler int((s[2] + 0.5) // 2)
?
Or int(np.ceil(s[2] * 0.5))
?
@@ -113,7 +113,7 @@ def residual_block(l, increase_dim=False, projection=False): | |||
block = NonlinearityLayer(ElemwiseSumLayer([stack_2, projection]),nonlinearity=rectify) | |||
else: | |||
# identity shortcut, as option A in paper | |||
identity = ExpressionLayer(l, lambda X: X[:, :, ::2, ::2], lambda s: (s[0], s[1], s[2]//2, s[3]//2)) | |||
identity = ExpressionLayer(l, lambda X: X[:, :, ::2, ::2], lambda s: (s[0], s[1], int((s[2] + 0.5) // 2), int((s[3] + 0.5) // 2))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, it should have been (s[2]+1)//2
. This rounds up and doesn't need an int
conversion either. Adding +.5
before the division was wrong, it should have been after the division as in int(s[2]/2. + .5)
, sorry.
Perfect, thanks. Can you squash this into a single commit?
|
Shape division was rounded down, but when the dimension is odd it should be rounded up