-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [feature] CONTRASTIVE REPRESENTATION DISTILLATION with dataset wrapper (#281) * init * TD: CRDLoss * complete UT * fix docstrings * fix ci * update * fix CI * DONE * maintain CRD dataset unique funcs as a mixin * maintain CRD dataset unique funcs as a mixin * maintain CRD dataset unique funcs as a mixin * add UT: CRD_ClsDataset * init * TODO: UT test formatting. * init * crd dataset wrapper * update docstring Co-authored-by: huangpengsheng <huangpengsheng@sensetime.com> * [Improvement] Update estimator with api revision (#277) * update estimator usage and fix bugs * refactor api of estimator & add inner check methods * fix docstrings * update search loop and config * fix lint * update unittest * decouple mmdet dependency and fix lint Co-authored-by: humu789 <humu@pjlab.org.cn> * [Fix] Fix tracer (#273) * test image_classifier_loss_calculator * fix backward tracer * update SingleStageDetectorPseudoLoss * merge * [Feature] Add Dsnas Algorithm (#226) * [tmp] Update Dsnas * [tmp] refactor arch_loss & flops_loss * Update Dsnas & MMRAZOR_EVALUATOR: 1. finalized compute_loss & handle_grads in algorithm; 2. add MMRAZOR_EVALUATOR; 3. fix bugs. * Update lr scheduler & fix a bug: 1. update param_scheduler & lr_scheduler for dsnas; 2. fix a bug of switching to finetune stage. * remove old evaluators * remove old evaluators * update param_scheduler config * merge dev-1.x into gy/estimator * add flops_loss in Dsnas using ResourcesEstimator * get resources before mutator.prepare_from_supernet * delete unness broadcast api from gml * broadcast spec_modules_resources when estimating * update early fix mechanism for Dsnas * fix merge * update units in estimator * minor change * fix data_preprocessor api * add flops_loss_coef * remove DsnasOptimWrapper * fix bn eps and data_preprocessor * fix bn weight decay bug * add betas for mutator optimizer * set diff_rank_seed=True for dsnas * fix start_factor of lr when warm up * remove .module in non-ddp mode * add GlobalAveragePoolingWithDropout * add UT for dsnas * remove unness channel adjustment for shufflenetv2 * update supernet configs * delete unness dropout * delete unness part with minor change on dsnas * minor change on the flag of search stage * update README and subnet configs * add UT for OneHotMutableOP * [Feature] Update train (#279) * support auto resume * add enable auto_scale_lr in train.py * support '--amp' option * [Fix] Fix darts metafile (#278) fix darts metafile * fix ci (#284) * fix ci for circle ci * fix bug in test_metafiles * add pr_stage_test for github ci * add multiple version * fix ut * fix lint * Temporarily skip dataset UT * update github ci * add github lint ci * install wheel * remove timm from requirements * install wheel when test on windows * fix error * fix bug * remove github windows ci * fix device error of arch_params when DsnasDDP * fix CRD dataset ut * fix scope error * rm test_cuda in workflows of github * [Doc] fix typos in en/usr_guides Co-authored-by: liukai <liukai@pjlab.org.cn> Co-authored-by: pppppM <gjf_mail@126.com> Co-authored-by: gaoyang07 <1546308416@qq.com> Co-authored-by: huangpengsheng <huangpengsheng@sensetime.com> Co-authored-by: SheffieldCao <1751899@tongji.edu.cn> * fix bug when python=3.6 * fix lint * fix bug when test using cpu only * refine ci * fix error in ci * try ci * update repr of Channel * fix error * mv init_from_predefined_model to MutableChannelUnit * move tests * update SquentialMutableChannel * update l1 mutable channel unit * add OneShotMutableChannel * candidate_mode -> choice_mode * update docstring * change ci Co-authored-by: P.Huang <37200926+FreakieHuang@users.noreply.github.com> Co-authored-by: huangpengsheng <huangpengsheng@sensetime.com> Co-authored-by: Yang Gao <Gary1546308416AL@gmail.com> Co-authored-by: humu789 <humu@pjlab.org.cn> Co-authored-by: whcao <41630003+HIT-cwh@users.noreply.github.com> Co-authored-by: liukai <liukai@pjlab.org.cn> Co-authored-by: pppppM <gjf_mail@126.com> Co-authored-by: gaoyang07 <1546308416@qq.com> Co-authored-by: SheffieldCao <1751899@tongji.edu.cn>
- Loading branch information
1 parent
8330b62
commit 3715bbc
Showing
35 changed files
with
354 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .base_mutable_channel import BaseMutableChannel | ||
from .units import (ChannelUnitType, L1MutableChannelUnit, | ||
MutableChannelUnit, OneShotMutableChannelUnit, | ||
SequentialMutableChannelUnit, SlimmableChannelUnit) | ||
from .mutable_channel_container import MutableChannelContainer | ||
from .oneshot_mutalbe_channel import OneShotMutableChannel | ||
from .sequential_mutable_channel import SquentialMutableChannel | ||
from .simple_mutable_channel import SimpleMutableChannel | ||
from .units import (ChannelUnitType, L1MutableChannelUnit, MutableChannelUnit, | ||
OneShotMutableChannelUnit, SequentialMutableChannelUnit, | ||
SlimmableChannelUnit) | ||
|
||
__all__ = [ | ||
'SimpleMutableChannel', 'L1MutableChannelUnit', | ||
'SequentialMutableChannelUnit', 'MutableChannelUnit', | ||
'OneShotMutableChannelUnit', 'SlimmableChannelUnit', | ||
'BaseMutableChannel', 'MutableChannelContainer', 'SquentialMutableChannel', | ||
'ChannelUnitType' | ||
'OneShotMutableChannelUnit', 'SlimmableChannelUnit', 'BaseMutableChannel', | ||
'MutableChannelContainer', 'SquentialMutableChannel', 'ChannelUnitType', | ||
'OneShotMutableChannel' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
mmrazor/models/mutables/mutable_channel/oneshot_mutalbe_channel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from typing import List, Union | ||
|
||
from .sequential_mutable_channel import SquentialMutableChannel | ||
|
||
|
||
class OneShotMutableChannel(SquentialMutableChannel): | ||
"""OneShotMutableChannel is a subclass of SquentialMutableChannel. The | ||
difference is that a OneShotMutableChannel limits the candidates of the | ||
choice. | ||
Args: | ||
num_channels (int): number of channels. | ||
candidate_choices (List[Union[float, int]], optional): A list of | ||
candidate width ratios. Each candidate indicates how many | ||
channels to be reserved. Defaults to []. | ||
choice_mode (str, optional): Mode of choices. Defaults to 'number'. | ||
""" | ||
|
||
def __init__(self, | ||
num_channels: int, | ||
candidate_choices: List[Union[float, int]] = [], | ||
choice_mode='number', | ||
**kwargs): | ||
super().__init__(num_channels, choice_mode, **kwargs) | ||
self.candidate_choices = candidate_choices | ||
if candidate_choices == []: | ||
candidate_choices.append(num_channels if self.is_num_mode else 1.0) | ||
|
||
@property | ||
def current_choice(self) -> Union[int, float]: | ||
"""Get current choice.""" | ||
return super().current_choice | ||
|
||
@current_choice.setter | ||
def current_choice(self, choice: Union[int, float]): | ||
"""Set current choice.""" | ||
assert choice in self.candidate_choices | ||
SquentialMutableChannel.current_choice.fset( # type: ignore | ||
self, # type: ignore | ||
choice) # type: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.