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

consistent mean calculation with std calculation #24

Open
huangeddie opened this issue Aug 24, 2020 · 2 comments
Open

consistent mean calculation with std calculation #24

huangeddie opened this issue Aug 24, 2020 · 2 comments

Comments

@huangeddie
Copy link

Hi in the Conv2d with WS, you computed the mean as
weight_mean = weight.mean(dim=1, keepdim=True).mean(dim=2, keepdim=True).mean(dim=3, keepdim=True)

why don't you do something like
weight_mean = weight.view(weight.shape[0], -1).mean(dim=1).view(-1, 1, 1, 1)

it would be consistent with what you did with the standard deviation as well

@huangeddie
Copy link
Author

I also don't think
the expand_as in weight = (weight - weight_mean) / std.expand_as(weight) is necessary since std should have the same number of dimensions as weight

@joe-siyuan-qiao
Copy link
Owner

You can take a look at

https://github.com/open-mmlab/mmcv/blob/d5cbf7eed1269095bfba1a07913efbbc99d2d10b/mmcv/cnn/bricks/conv_ws.py

which provides a nicer-looking implementation.

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

No branches or pull requests

2 participants