-
Notifications
You must be signed in to change notification settings - Fork 13
/
fixmatchccssl_exp512_cifar10_wres_x2_b1x64_l4000_soft.py
125 lines (113 loc) · 3.64 KB
/
fixmatchccssl_exp512_cifar10_wres_x2_b1x64_l4000_soft.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
""" The Code is under Tencent Youtu Public Rule
config for training
althorithsm: FixMatch+CCSSL
datastet: customized dataset semi-inat
backbone: resnet50
batch per GPU: 16
num of GPUs: 1
this file is organized in the form of
|-train
|-training related main options
|-trainer():SSL althorithsm
|-model
|-data
|-type: CIFAR10/CIFAR100/STL-10/customized dataset
|-num_labeled:num of labeled data
|-other data related options
|-transforms
|-other options
Training 512 epochs, with no T_push because of low noisy ratio
"""
train = dict(eval_step=1024,
total_steps=1024*512,
trainer=dict(type="FixMatchCCSSL",
threshold=0.95,
T=1.,
temperature=0.07,
lambda_u=1.,
lambda_contrast=1,
contrast_with_softlabel= True,
loss_x=dict(
type="cross_entropy",
reduction="mean"),
loss_u=dict(
type="cross_entropy",
reduction="none"),
))
num_classes = 10
# seed = 1
model = dict(
type="wideresnet",
depth=28,
widen_factor=2,
dropout=0,
num_classes=num_classes,
proj=True
)
cifar10_mean = (0.4914, 0.4822, 0.4465)
cifar10_std = (0.2471, 0.2435, 0.2616)
data = dict(
# CIFAR10SSL, CIFAR100SSL
type="CIFAR10SSL",
num_workers=4,
num_labeled=4000,
num_classes=num_classes,
batch_size=64,
expand_labels=False,
mu=7,
root="./data/CIFAR",
lpipelines=[[
dict(type="RandomHorizontalFlip"),
dict(type="RandomCrop",
size=32,
padding=int(32 * 0.125),
padding_mode='reflect'),
dict(type="ToTensor"),
dict(type="Normalize", mean=cifar10_mean, std=cifar10_std)
]],
upipelinse=[[
dict(type="RandomHorizontalFlip"),
dict(type="RandomCrop",
size=32,
padding=int(32 * 0.125),
padding_mode='reflect'),
dict(type="ToTensor"),
dict(type="Normalize", mean=cifar10_mean, std=cifar10_std)],[
dict(type="RandomHorizontalFlip"),
dict(type="RandomCrop",
size=32,
padding=int(32 * 0.125),
padding_mode='reflect'),
dict(type="RandAugmentMC", n=2, m=10),
dict(type="ToTensor"),
dict(type="Normalize", mean=cifar10_mean, std=cifar10_std)],[
dict(type="RandomResizedCrop",size=32),
dict(type="RandomHorizontalFlip"),
dict(type="RandomApply",
transforms=[
dict(type="ColorJitter",
brightness=0.4,
contrast=0.4,
saturation=0.4,
hue=0.1),
],
p=0.8),
dict(type="RandomGrayscale",p=0.2),
dict(type="ToTensor")]],
vpipeline=[
dict(type="ToTensor"),
dict(type="Normalize", mean=cifar10_mean, std=cifar10_std)
])
scheduler = dict(
type='cosine_schedule_with_warmup',
num_warmup_steps=0,
num_training_steps=train['total_steps']
)
ema = dict(use=True, pseudo_with_ema=False, decay=0.999)
#apex AMP optimization level selected in ['O0', 'O1', 'O2', and 'O3']." "See details at https://nvidia.github.io/apex/amp.html
amp = dict(use=False, opt_level="O1")
log = dict(interval=50)
ckpt = dict(interval=1)
evaluation = dict(eval_both=True)
# optimizer
optimizer = dict(type='SGD', lr=0.03, momentum=0.9, weight_decay=0.001, nesterov=True)