update for deepvoice3, fix weight norm
This commit is contained in:
parent
8505805dad
commit
ff1d66ea94
|
@ -196,8 +196,8 @@ if __name__ == "__main__":
|
||||||
beta1,
|
beta1,
|
||||||
beta2,
|
beta2,
|
||||||
epsilon=epsilon,
|
epsilon=epsilon,
|
||||||
parameter_list=dv3.parameters())
|
parameter_list=dv3.parameters(),
|
||||||
gradient_clipper = fluid.dygraph_grad_clip.GradClipByGlobalNorm(0.1)
|
grad_clip=fluid.clip.GradientClipByGlobalNorm(0.1))
|
||||||
|
|
||||||
# generation
|
# generation
|
||||||
synthesis_config = config["synthesis"]
|
synthesis_config = config["synthesis"]
|
||||||
|
@ -258,15 +258,19 @@ if __name__ == "__main__":
|
||||||
text_lengths, frames)
|
text_lengths, frames)
|
||||||
l = losses["loss"]
|
l = losses["loss"]
|
||||||
l.backward()
|
l.backward()
|
||||||
|
|
||||||
# record learning rate before updating
|
# record learning rate before updating
|
||||||
writer.add_scalar("learning_rate",
|
writer.add_scalar("learning_rate",
|
||||||
optim._learning_rate.step().numpy(), global_step)
|
optim._learning_rate.step().numpy(), global_step)
|
||||||
optim.minimize(l, grad_clip=gradient_clipper)
|
optim.minimize(l)
|
||||||
optim.clear_gradients()
|
optim.clear_gradients()
|
||||||
|
|
||||||
# ==================all kinds of tedious things=================
|
# ==================all kinds of tedious things=================
|
||||||
# record step loss into tensorboard
|
# record step loss into tensorboard
|
||||||
step_loss = {k: v.numpy()[0] for k, v in losses.items()}
|
step_loss = {
|
||||||
|
k: v.numpy()[0]
|
||||||
|
for k, v in losses.items() if v is not None
|
||||||
|
}
|
||||||
tqdm.tqdm.write("global_step: {}\tloss: {}".format(
|
tqdm.tqdm.write("global_step: {}\tloss: {}".format(
|
||||||
global_step, step_loss["loss"]))
|
global_step, step_loss["loss"]))
|
||||||
for k, v in step_loss.items():
|
for k, v in step_loss.items():
|
||||||
|
|
|
@ -262,7 +262,7 @@ class TTSLoss(object):
|
||||||
if compute_lin_loss:
|
if compute_lin_loss:
|
||||||
lin_hyp = lin_hyp[:, :-self.time_shift, :]
|
lin_hyp = lin_hyp[:, :-self.time_shift, :]
|
||||||
lin_ref = lin_ref[:, self.time_shift:, :]
|
lin_ref = lin_ref[:, self.time_shift:, :]
|
||||||
lin_mask = lin_mask[:, self.time_shift:, :]
|
lin_mask = lin_mask[:, self.time_shift:]
|
||||||
lin_l1_loss = self.l1_loss(
|
lin_l1_loss = self.l1_loss(
|
||||||
lin_hyp, lin_ref, lin_mask, priority_bin=self.priority_bin)
|
lin_hyp, lin_ref, lin_mask, priority_bin=self.priority_bin)
|
||||||
lin_bce_loss = self.binary_divergence(lin_hyp, lin_ref, lin_mask)
|
lin_bce_loss = self.binary_divergence(lin_hyp, lin_ref, lin_mask)
|
||||||
|
@ -273,7 +273,7 @@ class TTSLoss(object):
|
||||||
if compute_mel_loss:
|
if compute_mel_loss:
|
||||||
mel_hyp = mel_hyp[:, :-self.time_shift, :]
|
mel_hyp = mel_hyp[:, :-self.time_shift, :]
|
||||||
mel_ref = mel_ref[:, self.time_shift:, :]
|
mel_ref = mel_ref[:, self.time_shift:, :]
|
||||||
mel_mask = mel_mask[:, self.time_shift:, :]
|
mel_mask = mel_mask[:, self.time_shift:]
|
||||||
mel_l1_loss = self.l1_loss(mel_hyp, mel_ref, mel_mask)
|
mel_l1_loss = self.l1_loss(mel_hyp, mel_ref, mel_mask)
|
||||||
mel_bce_loss = self.binary_divergence(mel_hyp, mel_ref, mel_mask)
|
mel_bce_loss = self.binary_divergence(mel_hyp, mel_ref, mel_mask)
|
||||||
# print("=====>", mel_l1_loss.numpy()[0], mel_bce_loss.numpy()[0])
|
# print("=====>", mel_l1_loss.numpy()[0], mel_bce_loss.numpy()[0])
|
||||||
|
|
|
@ -31,8 +31,10 @@ def compute_position_embedding(radians, speaker_position_rate):
|
||||||
"""
|
"""
|
||||||
_, embed_dim = radians.shape
|
_, embed_dim = radians.shape
|
||||||
batch_size = speaker_position_rate.shape[0]
|
batch_size = speaker_position_rate.shape[0]
|
||||||
speaker_position_rate = F.unsqueeze(speaker_position_rate, [1, 2])
|
scaled_radians = F.elementwise_mul(
|
||||||
scaled_radians = speaker_position_rate * radians
|
F.expand(F.unsqueeze(radians, [0]), [batch_size, 1, 1]),
|
||||||
|
speaker_position_rate,
|
||||||
|
axis=0)
|
||||||
|
|
||||||
odd_mask = (np.arange(embed_dim) % 2).astype(np.float32)
|
odd_mask = (np.arange(embed_dim) % 2).astype(np.float32)
|
||||||
odd_mask = dg.to_variable(odd_mask)
|
odd_mask = dg.to_variable(odd_mask)
|
||||||
|
|
|
@ -84,13 +84,15 @@ class WeightNormWrapper(dg.Layer):
|
||||||
w_v,
|
w_v,
|
||||||
self.create_parameter(
|
self.create_parameter(
|
||||||
shape=original_weight.shape, dtype=original_weight.dtype))
|
shape=original_weight.shape, dtype=original_weight.dtype))
|
||||||
F.assign(original_weight, getattr(self, w_v))
|
with dg.no_grad():
|
||||||
|
F.assign(original_weight, getattr(self, w_v))
|
||||||
delattr(layer, param_name)
|
delattr(layer, param_name)
|
||||||
temp = norm_except(getattr(self, w_v), self.dim, self.power)
|
temp = norm_except(getattr(self, w_v), self.dim, self.power)
|
||||||
self.add_parameter(
|
self.add_parameter(
|
||||||
w_g, self.create_parameter(
|
w_g, self.create_parameter(
|
||||||
shape=temp.shape, dtype=temp.dtype))
|
shape=temp.shape, dtype=temp.dtype))
|
||||||
F.assign(temp, getattr(self, w_g))
|
with dg.no_grad():
|
||||||
|
F.assign(temp, getattr(self, w_g))
|
||||||
|
|
||||||
# also set this when setting up
|
# also set this when setting up
|
||||||
setattr(self.layer, self.param_name,
|
setattr(self.layer, self.param_name,
|
||||||
|
|
Loading…
Reference in New Issue