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

Fix GroupNormalization #611

Merged
merged 2 commits into from
Dec 2, 2019
Merged

Fix GroupNormalization #611

merged 2 commits into from
Dec 2, 2019

Conversation

DawyD
Copy link
Contributor

@DawyD DawyD commented Oct 21, 2019

  • Fix a bug, where the GroupNormalization layer was normalizing over the second axis instead of the selected axis.
  • Update tests (which seem to be irrelevant anyway)

* Fix a bug, where the GroupNormalization layer was normalizing over the second axis instead of the selected axis.
* Update tests (which seem to be irrelevant anyway)
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@DawyD
Copy link
Contributor Author

DawyD commented Oct 21, 2019

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@seanpmorgan
Copy link
Member

Thanks @DawyD!

@Smokrow could you take a look as code owner? We might need add additional test cases

@Smokrow
Copy link
Contributor

Smokrow commented Oct 25, 2019

As far as I see it the reduction is working as intended.
The axis that is introduced is the group axis and should always be on position 1.

@DawyD
Copy link
Contributor Author

DawyD commented Oct 28, 2019

The problem lies in the reshaping. tf.reshape reads and writes the elements in C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest.

You insert a new axis at index 1 that has size nr_groups and then you reshape assuming that the selected axis will be split into the inserted axis. In your code, this works only if the selected axis is the axis with index 2. If you select, for example, the axis with index 4, the axis that is split into the inserted one is the axis with index 2 and not 4.

@Smokrow
Copy link
Contributor

Smokrow commented Nov 2, 2019

Hey there. I completely missed this one. Thank you.
@seanpmorgan the fix looks good.

@Smokrow
Copy link
Contributor

Smokrow commented Nov 2, 2019

@seanpmorgan This will actually change the behavior of the layer since the GroupAxis will be moved to a different position. I am not sure if this can cause trouble down the line. Maybe we should fix that. What do you think?

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @DawyD! Apologies for the delayed response, it's been a busy month. As you mentioned the test cases here are only replicating the algorithm in numpy, not verifying against a known expected value. I've created #731 to improve them.

@seanpmorgan
Copy link
Member

@seanpmorgan This will actually change the behavior of the layer since the GroupAxis will be moved to a different position. I am not sure if this can cause trouble down the line. Maybe we should fix that. What do you think?

Since the group axis only exists while reshaping in the layer call this shouldn't produce any side-effects as far as I can tell.

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

Successfully merging this pull request may close these issues.

5 participants