-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhparams.py
279 lines (241 loc) · 5.38 KB
/
hparams.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
HPARAMS_REGISTRY = {}
MODEL_LIST = {
1: ('vq1', 'lm1'),
2: ('vq1', 'lm2'),
3: ('vq1', 'lm3'),
4: ('vq1', 'lm4'),
5: ('vq1', 'lm5'),
6: ('vq1', 'lm6'),
7: ('vq1', 'lm7'),
8: ('vq1', 'lm8'),
9: ('vq2', 'lm1'),
10: ('vq3', 'lm1'),
11: ('vq1', 'lm9'),
12: ('vq1', 'lm10'),
21: ('vq4', 'lm1'),
22: ('vq4', 'lm9')
}
class Hyperparams(dict):
def __getattr__(self, attr):
return self[attr]
def __setattr__(self, attr, value):
self[attr] = value
LM_DEFAULTS = Hyperparams(
batch_size=16,
sample_step=10,
ckpt_dir='ckpt/',
path='data/',
)
VQ_DEFAULTS = Hyperparams(
batch_size=32,
sample_step=50,
ckpt_dir='ckpt/',
path='data/',
)
def setup_lm_hparams(hparam_set_names):
# hparam_set_names = (vqvae_hparam, lm_hparam)
H = Hyperparams()
vqvae_sets = HPARAMS_REGISTRY[hparam_set_names[0].strip()]
lm_sets = HPARAMS_REGISTRY[hparam_set_names[1].strip()]
H.update(LM_DEFAULTS)
H.update(vqvae_sets)
H['vq_name'] = H['name']
H.update(lm_sets)
return H
def setup_vq_hparams(hparam_set_name):
# hparam_set_name = vqvae_hparam
print(f'set up {hparam_set_name} hparam')
H = Hyperparams()
vqvae_sets = HPARAMS_REGISTRY[hparam_set_name.strip()]
H.update(VQ_DEFAULTS)
H.update(vqvae_sets)
return H
OPT = Hyperparams(
epochs=1000,
lr=0.0003,
clip=1.0,
beta1=0.9,
beta2=0.999,
ignore_grad_norm=0,
weight_decay=0.0,
eps=1e-08,
lr_warmup=100.0,
lr_decay=10000000.0,
lr_gamma=1.0,
lr_scale=1.0,
lr_use_linear_decay=False,
lr_start_linear_decay=0,
lr_use_cosine_decay=False,
fp16_opt = False,
prior = True,
restore_prior = '',
fp16 = False,
)
MEL = Hyperparams(
n_fft = 1024,
hop_length = 256,
win_length = 1024,
sampling_rate = 44100,
n_mel_channels = 80,
extension = '.wav',
mel_fmin=0.0,
mel_fmax=None,
)
vq1 = Hyperparams(
# codebook 32 | 1024
name = 'vq1',
codebook_size = 32,
upsample_ratios = [2, 2],
downsample_ratios = [0.5, 0.5],
commit_beta = 0.02,
)
HPARAMS_REGISTRY['vq1'] = vq1
vq2 = Hyperparams(
# codebook 64 | 512
name = 'vq2',
codebook_size = 64,
upsample_ratios = [4, 2],
downsample_ratios = [0.5, 0.25],
commit_beta = 0.02,
)
HPARAMS_REGISTRY['vq2'] = vq2
vq3 = Hyperparams(
# codebook 32 | 2048
name = 'vq3',
batch_size=6,
codebook_size = 32,
upsample_ratios = [2, 1],
downsample_ratios = [1, .5],
commit_beta = 0.02,
)
HPARAMS_REGISTRY['vq3'] = vq3
vq4 = Hyperparams(
# codebook 32 | 1024, indentical to vq1 but differnet dataset
name = 'vq4',
codebook_size = 32,
upsample_ratios = [2, 2],
downsample_ratios = [0.5, 0.5],
commit_beta = 0.02,
)
HPARAMS_REGISTRY['vq4'] = vq4
lm1 = Hyperparams(
# Raw beat activation (Low-level) w/o in-attention
name = 'lm1',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = 'low'
)
HPARAMS_REGISTRY['lm1'] = lm1
lm2 = Hyperparams(
# No beat activation w/o in-attention
name = 'lm2',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = None,
)
HPARAMS_REGISTRY['lm2'] = lm2
lm3 = Hyperparams(
# Raw beat activation (Low-level) w/ in-attention
name = 'lm3',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = 'low',
)
HPARAMS_REGISTRY['lm3'] = lm3
lm4 = Hyperparams(
# lm1 but d_model=1024
name = 'lm4',
batch_size = 8,
enc_layers = 20,
dec_layers= 9,
d_model= 1024,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = 'low',
)
HPARAMS_REGISTRY['lm4'] = lm4
lm5 = Hyperparams(
# beat / downbeat / non-beat 3 token beat embed (High-level) w/o in-attention
name = 'lm5',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = 'high',
)
HPARAMS_REGISTRY['lm5'] = lm5
lm6 = Hyperparams(
# beat / downbeat / non-beat 3 token beat embed (High-level) w/ in-attention
name = 'lm6',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = 'high',
)
HPARAMS_REGISTRY['lm6'] = lm6
lm7 = Hyperparams(
# onset/ non-onset 2 tokens beat embed (Mid-level) w/o in-attention
name = 'lm7',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = 'mid',
)
HPARAMS_REGISTRY['lm7'] = lm7
lm8 = Hyperparams(
# onset/ non-onset 2 tokens beat embed (Mid-level) w/ in-attention
name = 'lm8',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = 'mid',
)
HPARAMS_REGISTRY['lm8'] = lm8
lm9 = Hyperparams(
# No encoder w/ raw beat info (Low-level)
name = 'lm9',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = 'low',
)
HPARAMS_REGISTRY['lm9'] = lm9
lm10 = Hyperparams(
# No encoder w/o beat info
name = 'lm10',
enc_layers = 20,
dec_layers= 9,
d_model= 512,
dropout = 0.2,
heads = 2,
blocks = 16,
binfo_type = None,
)
HPARAMS_REGISTRY['lm10'] = lm10