forked from r9y9/wavenet_vocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hparams.py
133 lines (111 loc) · 3.75 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
from wavenet_vocoder.tfcompat.hparam import HParams
import numpy as np
# NOTE: If you want full control for model architecture. please take a look
# at the code and change whatever you want. Some hyper parameters are hardcoded.
# Default hyperparameters:
hparams = HParams(
name="wavenet_vocoder",
# Input type:
# 1. raw [-1, 1]
# 2. mulaw [-1, 1]
# 3. mulaw-quantize [0, mu]
# If input_type is raw or mulaw, network assumes scalar input and
# discretized mixture of logistic distributions output, otherwise one-hot
# input and softmax output are assumed.
# **NOTE**: if you change the one of the two parameters below, you need to
# re-run preprocessing before training.
input_type="raw",
quantize_channels=65536, # 65536 or 256
# Audio:
# time-domain pre/post-processing
# e.g., preemphasis/inv_preemphasis
# ref: LPCNet https://arxiv.org/abs/1810.11846
preprocess="",
postprocess="",
# waveform domain scaling
global_gain_scale=1.0,
sample_rate=22050,
# this is only valid for mulaw is True
silence_threshold=2,
num_mels=80,
fmin=125,
fmax=7600,
fft_size=1024,
# shift can be specified by either hop_size or frame_shift_ms
hop_size=256,
frame_shift_ms=None,
win_length=1024,
win_length_ms=-1.0,
window="hann",
# DC removal
highpass_cutoff=70.0,
# Parametric output distribution type for scalar input
# 1) Logistic or 2) Normal
output_distribution="Logistic",
log_scale_min=-16.0,
# Model:
# This should equal to `quantize_channels` if mu-law quantize enabled
# otherwise num_mixture * 3 (pi, mean, log_scale)
# single mixture case: 2
out_channels=10 * 3,
layers=24,
stacks=4,
residual_channels=128,
gate_channels=256, # split into 2 gropus internally for gated activation
skip_out_channels=128,
dropout=0.0,
kernel_size=3,
# Local conditioning (set negative value to disable))
cin_channels=80,
cin_pad=2,
# If True, use transposed convolutions to upsample conditional features,
# otherwise repeat features to adjust time resolution
upsample_conditional_features=True,
upsample_net="ConvInUpsampleNetwork",
upsample_params={
"upsample_scales": [4, 4, 4, 4], # should np.prod(upsample_scales) == hop_size
},
# Global conditioning (set negative value to disable)
# currently limited for speaker embedding
# this should only be enabled for multi-speaker dataset
gin_channels=-1, # i.e., speaker embedding dim
n_speakers=7, # 7 for CMU ARCTIC
# Data loader
pin_memory=True,
num_workers=2,
# Loss
# Training:
batch_size=8,
optimizer="Adam",
optimizer_params={
"lr": 1e-3,
"eps": 1e-8,
"weight_decay": 0.0,
},
# see lrschedule.py for available lr_schedule
lr_schedule="step_learning_rate_decay",
lr_schedule_kwargs={"anneal_rate": 0.5, "anneal_interval": 200000},
max_train_steps=1000000,
nepochs=2000,
clip_thresh=-1,
# max time steps can either be specified as sec or steps
# if both are None, then full audio samples are used in a batch
max_time_sec=None,
max_time_steps=10240, # 256 * 40
# Hold moving averaged parameters and use them for evaluation
exponential_moving_average=True,
# averaged = decay * averaged + (1 - decay) * x
ema_decay=0.9999,
# Save
# per-step intervals
checkpoint_interval=100000,
train_eval_interval=100000,
# per-epoch interval
test_eval_epoch_interval=50,
save_optimizer_state=True,
# Eval:
)
def hparams_debug_string():
values = hparams.values()
hp = [' %s: %s' % (name, values[name]) for name in sorted(values)]
return 'Hyperparameters:\n' + '\n'.join(hp)