forked from open-mmlab/mmrazor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
darts_subnet_1xb96_cifar10.py
94 lines (88 loc) · 3.04 KB
/
darts_subnet_1xb96_cifar10.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
_base_ = [
'../../_base_/datasets/mmcls/cifar10_bs96_cutout.py',
'../../_base_/mmcls_runtime.py'
]
model = dict(
type='mmcls.ImageClassifier',
backbone=dict(
type='DartsBackbone',
in_channels=3,
base_channels=36,
num_layers=20,
num_nodes=4,
stem_multiplier=3,
auxliary=True,
aux_channels=128,
aux_out_channels=768,
out_indices=(19, )),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='DartsSubnetClsHead',
num_classes=10,
in_channels=576,
aux_in_channels=768,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
aux_loss=dict(type='CrossEntropyLoss', loss_weight=0.4),
topk=(1, 5),
cal_acc=True),
)
# FIXME: you may replace this with the mutable_cfg searched by yourself
mutable_cfg = 'https://download.openmmlab.com/mmrazor/v0.1/nas/darts/darts_subnetnet_1xb96_cifar10/darts_subnetnet_1xb96_cifar10_acc-97.32_20211222-e5727921_mutable_cfg.yaml' # noqa: E501
algorithm = dict(
type='Darts',
architecture=dict(type='MMClsArchitecture', model=model),
mutator=dict(
type='DartsMutator',
placeholder_mapping=dict(
node=dict(
type='DifferentiableOP',
with_arch_param=False,
choices=dict(
zero=dict(type='DartsZero'),
skip_connect=dict(
type='DartsSkipConnect', use_drop_path=True),
max_pool_3x3=dict(
type='DartsPoolBN',
pool_type='max',
use_drop_path=True),
avg_pool_3x3=dict(
type='DartsPoolBN',
pool_type='avg',
use_drop_path=True),
sep_conv_3x3=dict(
type='DartsSepConv', kernel_size=3,
use_drop_path=True),
sep_conv_5x5=dict(
type='DartsSepConv', kernel_size=5,
use_drop_path=True),
dil_conv_3x3=dict(
type='DartsDilConv', kernel_size=3,
use_drop_path=True),
dil_conv_5x5=dict(
type='DartsDilConv', kernel_size=5,
use_drop_path=True),
)),
node_edge=dict(
type='DifferentiableEdge',
num_chosen=2,
with_arch_param=False,
)),
),
retraining=True,
unroll=False,
mutable_cfg=mutable_cfg)
data = dict(workers_per_gpu=8)
# optimizer
optimizer = dict(type='SGD', lr=0.025, momentum=0.9, weight_decay=0.0003)
optimizer_config = dict(grad_clip=dict(max_norm=5, norm_type=2))
# learning policy
lr_config = dict(policy='CosineAnnealing', min_lr=0)
runner = dict(type='EpochBasedRunner', max_epochs=600)
custom_hooks = [
dict(
type='DropPathProbHook',
max_prob=0.2,
interval=1,
priority=70,
)
]