-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Mobilenet Series Search Space (#82)
* add mbv2 block and identity * add mbv2 block and identity unittests * expand_factor -> expand_ratio * add searchable mobilenet v2 * fix lints * add spos subnet retraining config * fix mmcls slurm search * add proxyless_gpu setting for mbv2 * use bn default * add angelnas spos config * update spos readme * fix SELayer's useage * add docstring * rename mbv2 to mb * add some unittest of mb * rename mb to mobilenet * add some rename-mb in configs * update README of spos * add rename-mb in unittest * update test_mmcls Co-authored-by: wutongshenqiu <[email protected]> Co-authored-by: humu789 <[email protected]>
- Loading branch information
1 parent
f59e059
commit ef1637e
Showing
13 changed files
with
799 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
stage_0_block_0: | ||
chosen: | ||
- mb_k3e1 | ||
stage_1_block_0: | ||
chosen: | ||
- mb_k5e3 | ||
stage_1_block_1: | ||
chosen: | ||
- mb_k5e3 | ||
stage_1_block_2: | ||
chosen: | ||
- identity | ||
stage_1_block_3: | ||
chosen: | ||
- mb_k3e3 | ||
stage_2_block_0: | ||
chosen: | ||
- mb_k3e3 | ||
stage_2_block_1: | ||
chosen: | ||
- identity | ||
stage_2_block_2: | ||
chosen: | ||
- identity | ||
stage_2_block_3: | ||
chosen: | ||
- mb_k3e3 | ||
stage_3_block_0: | ||
chosen: | ||
- mb_k7e6 | ||
stage_3_block_1: | ||
chosen: | ||
- identity | ||
stage_3_block_2: | ||
chosen: | ||
- mb_k7e3 | ||
stage_3_block_3: | ||
chosen: | ||
- mb_k7e3 | ||
stage_4_block_0: | ||
chosen: | ||
- mb_k3e3 | ||
stage_4_block_1: | ||
chosen: | ||
- mb_k3e3 | ||
stage_4_block_2: | ||
chosen: | ||
- mb_k7e3 | ||
stage_4_block_3: | ||
chosen: | ||
- mb_k5e3 | ||
stage_5_block_0: | ||
chosen: | ||
- mb_k5e6 | ||
stage_5_block_1: | ||
chosen: | ||
- mb_k7e3 | ||
stage_5_block_2: | ||
chosen: | ||
- mb_k7e3 | ||
stage_5_block_3: | ||
chosen: | ||
- mb_k7e3 | ||
stage_6_block_0: | ||
chosen: | ||
- mb_k5e6 |
20 changes: 20 additions & 0 deletions
20
configs/nas/spos/spos_evolution_search_mobilenet_proxyless_gpu_flops465_8xb512_in1k.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,20 @@ | ||
_base_ = ['./spos_supernet_mobilenet_proxyless_gpu_8xb128_in1k.py'] | ||
|
||
data = dict( | ||
samples_per_gpu=512, | ||
workers_per_gpu=16, | ||
) | ||
|
||
algorithm = dict(bn_training_mode=True) | ||
|
||
searcher = dict( | ||
type='EvolutionSearcher', | ||
candidate_pool_size=50, | ||
candidate_top_k=10, | ||
constraints=dict(flops=465 * 1e6), | ||
metrics='accuracy', | ||
score_key='accuracy_top-1', | ||
max_epoch=20, | ||
num_mutation=25, | ||
num_crossover=25, | ||
mutate_prob=0.1) |
27 changes: 27 additions & 0 deletions
27
configs/nas/spos/spos_mobilenet_for_check_ckpt_from_anglenas.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,27 @@ | ||
_base_ = [ | ||
'./spos_subnet_mobilenet_proxyless_gpu_8xb128_in1k.py', | ||
] | ||
|
||
img_norm_cfg = dict(mean=[0., 0., 0.], std=[1., 1., 1.], to_rgb=False) | ||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='RandomResizedCrop', size=224), | ||
dict(type='ColorJitter', brightness=0.4, contrast=0.4, saturation=0.4), | ||
dict(type='RandomFlip', flip_prob=0.5, direction='horizontal'), | ||
dict(type='Normalize', **img_norm_cfg), | ||
dict(type='ImageToTensor', keys=['img']), | ||
dict(type='ToTensor', keys=['gt_label']), | ||
dict(type='Collect', keys=['img', 'gt_label']) | ||
] | ||
test_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='Resize', size=(256, -1)), | ||
dict(type='CenterCrop', crop_size=224), | ||
dict(type='Normalize', **img_norm_cfg), | ||
dict(type='ImageToTensor', keys=['img']), | ||
dict(type='Collect', keys=['img']) | ||
] | ||
data = dict( | ||
train=dict(pipeline=train_pipeline), | ||
val=dict(pipeline=test_pipeline), | ||
test=dict(pipeline=test_pipeline)) |
10 changes: 10 additions & 0 deletions
10
configs/nas/spos/spos_subnet_mobilenet_proxyless_gpu_8xb128_in1k.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,10 @@ | ||
_base_ = [ | ||
'./spos_supernet_mobilenet_proxyless_gpu_8xb128_in1k.py', | ||
] | ||
|
||
algorithm = dict(retraining=True) | ||
evaluation = dict(interval=10000, metric='accuracy') | ||
checkpoint_config = dict(interval=30000) | ||
|
||
runner = dict(max_iters=300000) | ||
find_unused_parameters = False |
101 changes: 101 additions & 0 deletions
101
configs/nas/spos/spos_supernet_mobilenet_proxyless_gpu_8xb128_in1k.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,101 @@ | ||
_base_ = [ | ||
'../../_base_/datasets/mmcls/imagenet_bs128_colorjittor.py', | ||
'../../_base_/schedules/mmcls/imagenet_bs1024_spos.py', | ||
'../../_base_/mmcls_runtime.py' | ||
] | ||
norm_cfg = dict(type='BN') | ||
model = dict( | ||
type='mmcls.ImageClassifier', | ||
backbone=dict( | ||
type='SearchableMobileNet', | ||
first_channels=40, | ||
last_channels=1728, | ||
widen_factor=1.0, | ||
norm_cfg=norm_cfg, | ||
arch_setting_type='proxyless_gpu'), | ||
neck=dict(type='GlobalAveragePooling'), | ||
head=dict( | ||
type='LinearClsHead', | ||
num_classes=1000, | ||
in_channels=1728, | ||
loss=dict( | ||
type='LabelSmoothLoss', | ||
num_classes=1000, | ||
label_smooth_val=0.1, | ||
mode='original', | ||
loss_weight=1.0), | ||
topk=(1, 5), | ||
), | ||
) | ||
|
||
mutator = dict( | ||
type='OneShotMutator', | ||
placeholder_mapping=dict( | ||
searchable_blocks=dict( | ||
type='OneShotOP', | ||
choices=dict( | ||
mb_k3e3=dict( | ||
type='MBBlock', | ||
kernel_size=3, | ||
expand_ratio=3, | ||
norm_cfg=norm_cfg, | ||
act_cfg=dict(type='ReLU6')), | ||
mb_k5e3=dict( | ||
type='MBBlock', | ||
kernel_size=5, | ||
expand_ratio=3, | ||
norm_cfg=norm_cfg, | ||
act_cfg=dict(type='ReLU6')), | ||
mb_k7e3=dict( | ||
type='MBBlock', | ||
kernel_size=7, | ||
expand_ratio=3, | ||
norm_cfg=norm_cfg, | ||
act_cfg=dict(type='ReLU6')), | ||
mb_k3e6=dict( | ||
type='MBBlock', | ||
kernel_size=3, | ||
expand_ratio=6, | ||
norm_cfg=norm_cfg, | ||
act_cfg=dict(type='ReLU6')), | ||
mb_k5e6=dict( | ||
type='MBBlock', | ||
kernel_size=5, | ||
expand_ratio=6, | ||
norm_cfg=norm_cfg, | ||
act_cfg=dict(type='ReLU6')), | ||
mb_k7e6=dict( | ||
type='MBBlock', | ||
kernel_size=7, | ||
expand_ratio=6, | ||
norm_cfg=norm_cfg, | ||
act_cfg=dict(type='ReLU6')), | ||
identity=dict(type='Identity'))), | ||
first_blocks=dict( | ||
type='OneShotOP', | ||
choices=dict( | ||
mb_k3e1=dict( | ||
type='MBBlock', | ||
kernel_size=3, | ||
expand_ratio=1, | ||
norm_cfg=norm_cfg, | ||
act_cfg=dict(type='ReLU6')), )))) | ||
|
||
algorithm = dict( | ||
type='SPOS', | ||
architecture=dict( | ||
type='MMClsArchitecture', | ||
model=model, | ||
), | ||
mutator=mutator, | ||
distiller=None, | ||
retraining=False, | ||
) | ||
|
||
runner = dict(max_iters=150000) | ||
evaluation = dict(interval=10000, metric='accuracy') | ||
|
||
# checkpoint saving | ||
checkpoint_config = dict(interval=30000) | ||
|
||
find_unused_parameters = True |
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,5 +1,6 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .darts_backbone import DartsBackbone | ||
from .searchable_mobilenet import SearchableMobileNet | ||
from .searchable_shufflenet_v2 import SearchableShuffleNetV2 | ||
|
||
__all__ = ['DartsBackbone', 'SearchableShuffleNetV2'] | ||
__all__ = ['DartsBackbone', 'SearchableShuffleNetV2', 'SearchableMobileNet'] |
Oops, something went wrong.