forked from open-mmlab/mmagic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbiggan_2xb25-500kiters_cifar10-32x32.py
88 lines (81 loc) · 2.27 KB
/
biggan_2xb25-500kiters_cifar10-32x32.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
_base_ = [
'../_base_/datasets/cifar10_noaug.py',
'../_base_/gen_default_runtime.py',
]
# define model
ema_config = dict(
type='ExponentialMovingAverage',
interval=1,
momentum=0.0001,
start_iter=1000)
model = dict(
type='BigGAN',
num_classes=10,
data_preprocessor=dict(
type='DataPreprocessor', output_channel_order='BGR'),
generator=dict(
type='BigGANGenerator',
output_scale=32,
noise_size=128,
num_classes=10,
base_channels=64,
with_shared_embedding=False,
sn_eps=1e-8,
sn_style='torch',
split_noise=False,
auto_sync_bn=False,
init_cfg=dict(type='N02')),
discriminator=dict(
type='BigGANDiscriminator',
input_scale=32,
num_classes=10,
base_channels=64,
sn_eps=1e-8,
sn_style='torch',
with_spectral_norm=True,
init_cfg=dict(type='N02')),
generator_steps=1,
discriminator_steps=4,
ema_config=ema_config)
# define dataset
train_dataloader = dict(batch_size=25, num_workers=8)
val_dataloader = dict(batch_size=25, num_workers=8)
test_dataloader = dict(batch_size=25, num_workers=8)
# VIS_HOOK
custom_hooks = [
dict(
type='VisualizationHook',
interval=5000,
fixed_input=True,
# vis ema and orig at the same time
vis_kwargs_list=dict(
type='Noise',
name='fake_img',
sample_model='ema/orig',
target_keys=['ema', 'orig'])),
]
optim_wrapper = dict(
generator=dict(optimizer=dict(type='Adam', lr=0.0002, betas=(0.0, 0.999))),
discriminator=dict(
optimizer=dict(type='Adam', lr=0.0002, betas=(0.0, 0.999))))
train_cfg = dict(max_iters=500000)
metrics = [
dict(
type='FrechetInceptionDistance',
prefix='FID-Full-50k',
fake_nums=50000,
inception_style='StyleGAN',
sample_model='ema'),
dict(
type='IS',
prefix='IS-50k',
fake_nums=50000,
inception_style='StyleGAN',
sample_model='ema')
]
# save multi best checkpoints
default_hooks = dict(
checkpoint=dict(
save_best=['FID-Full-50k/fid', 'IS-50k/is'], rule=['less', 'greater']))
val_evaluator = dict(metrics=metrics)
test_evaluator = dict(metrics=metrics)