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] Revise override in init_cfg #930

Merged
merged 6 commits into from
Apr 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mmcv/cnn/utils/weight_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,12 @@ def _initialize_override(module, override, cfg):
override = [override] if isinstance(override, dict) else override

for override_ in override:
if 'type' not in override_.keys():
override_.update(cfg)
name = override_.pop('name', None)
cp_cfg = copy.deepcopy(override_)
MeowZheng marked this conversation as resolved.
Show resolved Hide resolved
if 'type' not in cp_cfg.keys():
cp_cfg.update(cfg)
name = cp_cfg.pop('name', None)
if hasattr(module, name):
_initialize(getattr(module, name), override_, wholemodule=True)
_initialize(getattr(module, name), cp_cfg, wholemodule=True)
else:
raise RuntimeError(f'module did not have attribute {name}')

Expand Down