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

[Refactoring]Add Sequential with init_weight #884

Merged
merged 9 commits into from
Mar 17, 2021

Conversation

MeowZheng
Copy link
Collaborator

@MeowZheng MeowZheng commented Mar 12, 2021

As developers always used nn.Sequential to implement a submodule, I add Sequential with init_weight for parameters initialization with init_cfg. In addition, I override __repr__ to display initialization information.

example

seq_model_cfg = [
        dict(
            type='FooConv1d', init_cfg=dict(type='Constant', val=0., bias=1.)),
        dict(
            type='FooConv2d', init_cfg=dict(type='Constant', val=2., bias=3.)),
    ]
layers = [build_from_cfg(cfg, COMPONENTS) for cfg in seq_model_cfg]
seq_model = Sequential(*layers)
seq_model.init_weight()

@codecov
Copy link

codecov bot commented Mar 12, 2021

Codecov Report

Merging #884 (8f267a8) into master (73bff4e) will increase coverage by 0.00%.
The diff coverage is 71.42%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #884   +/-   ##
=======================================
  Coverage   66.58%   66.58%           
=======================================
  Files         145      145           
  Lines        8828     8841   +13     
  Branches     1605     1606    +1     
=======================================
+ Hits         5878     5887    +9     
- Misses       2633     2637    +4     
  Partials      317      317           
Flag Coverage Δ
unittests 66.58% <71.42%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmcv/runner/base_module.py 79.41% <69.23%> (-6.31%) ⬇️
mmcv/runner/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73bff4e...3c82d65. Read the comment docs.

@MeowZheng MeowZheng changed the title [Refactoring]Add BaseSequential with init_weight [Refactoring]Add Sequential with init_weight Mar 13, 2021
@ZwwWayne
Copy link
Collaborator

Should we also handle nn.ModuleList?

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.

3 participants