Skip to content

[Feature] add reduction for neck#978

Merged
mzr1996 merged 9 commits intoopen-mmlab:dev-1.xfrom
zzc98:add-reduction-neck
Nov 4, 2022
Merged

[Feature] add reduction for neck#978
mzr1996 merged 9 commits intoopen-mmlab:dev-1.xfrom
zzc98:add-reduction-neck

Conversation

@zzc98
Copy link
Copy Markdown
Contributor

@zzc98 zzc98 commented Aug 18, 2022

Motivation

In some cases, it is necessary to reduce the dimension of extracted feature, so Reduction is implemented in necks.

Use cases

model = dict(
    type='ImageClassifier',
    backbone=dict(
        type='ResNet',
        depth=101,
        num_stages=4,
        out_indices=(3,),
        style='pytorch'
    ),
    neck=[
        dict(type='GeneralizedMeanPooling'),
        dict(type='LinearReduction',
             in_channels=2048,
             out_channels=512,
             act_cfg=dict(type='ReLU'),
             norm_cfg=dict(type='BN1d')
             )
    ],
    head=dict(
        type='LinearClsHead',
        num_classes=1000,
        in_channels=512,
        loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
        topk=(1, 5),
    ),
)

Checklist

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, like docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects, like MMDet or MMSeg.
  • CLA has been signed and all committers have signed the CLA in this PR.

@zzc98 zzc98 changed the title feat: add reduction for neck [Feature] add reduction for neck Aug 18, 2022
@Ezra-Yu
Copy link
Copy Markdown
Collaborator

Ezra-Yu commented Sep 5, 2022

please rebase the branch to fix the conflict.

@zzc98 zzc98 force-pushed the add-reduction-neck branch from 9ef35a4 to 90254a8 Compare September 5, 2022 11:53
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 5, 2022

Codecov Report

Base: 0.02% // Head: 91.39% // Increases project coverage by +91.36% 🎉

Coverage data is based on head (7eaf7ca) compared to base (b8b31e9).
Patch has no changes to coverable lines.

Additional details and impacted files
@@             Coverage Diff              @@
##           dev-1.x     #978       +/-   ##
============================================
+ Coverage     0.02%   91.39%   +91.36%     
============================================
  Files          121      131       +10     
  Lines         8217     9804     +1587     
  Branches      1368     1543      +175     
============================================
+ Hits             2     8960     +8958     
+ Misses        8215      648     -7567     
- Partials         0      196      +196     
Flag Coverage Δ
unittests 91.39% <ø> (+91.36%) ⬆️

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

Impacted Files Coverage Δ
mmcls/apis/inference.py 0.00% <0.00%> (ø)
mmcls/datasets/transforms/compose.py
mmcls/models/backbones/mobilevit.py 91.15% <0.00%> (ø)
mmcls/models/backbones/deit3.py 94.52% <0.00%> (ø)
mmcls/models/backbones/edgenext.py 95.20% <0.00%> (ø)
mmcls/models/backbones/swin_transformer_v2.py 89.47% <0.00%> (ø)
mmcls/models/backbones/mvit.py 92.46% <0.00%> (ø)
mmcls/models/necks/reduction.py 100.00% <0.00%> (ø)
mmcls/models/utils/layer_scale.py 86.66% <0.00%> (ø)
mmcls/models/heads/efficientformer_head.py 93.10% <0.00%> (ø)
... and 121 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Ezra-Yu Ezra-Yu force-pushed the add-reduction-neck branch from 5471488 to 7eaf7ca Compare November 1, 2022 08:14
Copy link
Copy Markdown
Collaborator

@Ezra-Yu Ezra-Yu left a comment

Choose a reason for hiding this comment

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

LGTM.

@mzr1996 mzr1996 merged commit 9eb6fc4 into open-mmlab:dev-1.x Nov 4, 2022
mzr1996 pushed a commit to mzr1996/mmpretrain that referenced this pull request Nov 24, 2022
* feat: add reduction for neck

* feat: add reduction for neck

* feat: add reduction for neck

* feat:add linear reduction neck

* feat: add reduction neck

* mod out of linearReduction as tuple

* fix typo

* fix unit tests

* fix unit tests

Co-authored-by: Ezra-Yu <18586273+Ezra-Yu@users.noreply.github.com>
@zzc98 zzc98 deleted the add-reduction-neck branch May 5, 2023 10:55
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