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
DenseCL init weights copy query encoder weights to key encoder. #411
DenseCL init weights copy query encoder weights to key encoder. #411
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #411 +/- ##
==========================================
+ Coverage 72.47% 72.48% +0.01%
==========================================
Files 121 121
Lines 4759 4765 +6
Branches 763 763
==========================================
+ Hits 3449 3454 +5
Misses 1151 1151
- Partials 159 160 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
LGTM
One thing I noticed that is not optimal, is that the log info will still show that the key encoder weights did not change (due to it being printed in |
Currently, there is no way to overwrite the log for the the initialization log of the key encoder, unless the |
Hi! I see. So would that be done by using mmselfsup.utils.get_root_logger to get a logger and then log with that, or just a simple print statement? |
Better use |
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.
Thanks for the contribution. LGTM
* DenseCL init weights copy query encoder weights to key encoder. * Logger prints that key encoder is initialized with query encoder.
* DenseCL init weights copy query encoder weights to key encoder. * Logger prints that key encoder is initialized with query encoder.
…-mmlab#411) * DenseCL init weights copy query encoder weights to key encoder. * Logger prints that key encoder is initialized with query encoder.
* DenseCL init weights copy query encoder weights to key encoder. * Logger prints that key encoder is initialized with query encoder.
Motivation
DenseCL weight initialization is not done consistently with original repo, when loading ImageNet pre-trained weights to backbone, it will only get loaded to the query encoder, and not the key encoder, see original repo: https://github.com/WXinlong/DenseCL/blob/360df04ba25aca36d42e85c5a96552783568fccf/openselfsup/models/densecl.py#L36 and https://github.com/WXinlong/DenseCL/blob/360df04ba25aca36d42e85c5a96552783568fccf/openselfsup/models/densecl.py#L51-L58.
Fixes #404
Modification
DenseCL init includes calling super().init_weights() and then copying query encoder params to key encoder params.
Checklist
Before PR:
After PR: