Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

matteopresutto
Copy link

Shape division was rounded down, but when the dimension is odd it should be rounded up

@@ -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))))
Copy link
Member

@f0k f0k Jul 5, 2016

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)))
Copy link
Member

@f0k f0k Jul 5, 2016

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.

@f0k
Copy link
Member

f0k commented Jul 6, 2016

Perfect, thanks. Can you squash this into a single commit?

git reset --soft 41ed700
git commit --amend --no-edit
git push --force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants