mirror of https://github.com/coqui-ai/TTS.git
graves v2
This commit is contained in:
parent
cf7d968f57
commit
72817438db
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"model": "Tacotron2", // one of the model in models/
|
"model": "Tacotron2", // one of the model in models/
|
||||||
"run_name": "ljspeech-graves",
|
"run_name": "ljspeech-gravesv2",
|
||||||
"run_description": "tacotron2 wuth graves attention",
|
"run_description": "tacotron2 wuth graves attention",
|
||||||
|
|
||||||
// AUDIO PARAMETERS
|
// AUDIO PARAMETERS
|
||||||
|
|
|
@ -118,7 +118,7 @@ class GravesAttention(nn.Module):
|
||||||
|
|
||||||
def __init__(self, query_dim, K):
|
def __init__(self, query_dim, K):
|
||||||
super(GravesAttention, self).__init__()
|
super(GravesAttention, self).__init__()
|
||||||
self._mask_value = 0.0
|
self._mask_value = 1e-8
|
||||||
self.K = K
|
self.K = K
|
||||||
# self.attention_alignment = 0.05
|
# self.attention_alignment = 0.05
|
||||||
self.eps = 1e-5
|
self.eps = 1e-5
|
||||||
|
@ -165,12 +165,14 @@ class GravesAttention(nn.Module):
|
||||||
|
|
||||||
# attention GMM parameters
|
# attention GMM parameters
|
||||||
sig_t = torch.nn.functional.softplus(b_t) + self.eps
|
sig_t = torch.nn.functional.softplus(b_t) + self.eps
|
||||||
|
|
||||||
mu_t = self.mu_prev + torch.nn.functional.softplus(k_t)
|
mu_t = self.mu_prev + torch.nn.functional.softplus(k_t)
|
||||||
g_t = torch.softmax(g_t, dim=-1) / sig_t + self.eps
|
g_t = torch.softmax(g_t, dim=-1) / sig_t + self.eps
|
||||||
|
|
||||||
j = self.J[:inputs.size(1)+1]
|
j = self.J[:inputs.size(1)+1]
|
||||||
|
|
||||||
# attention weights
|
# attention weights
|
||||||
phi_t = g_t.unsqueeze(-1) * (1 / (1 + torch.exp((mu_t.unsqueeze(-1) - j) / sig_t.unsqueeze(-1))))
|
phi_t = g_t.unsqueeze(-1) * (1 / (1 + torch.sigmoid((mu_t.unsqueeze(-1) - j) / sig_t.unsqueeze(-1))))
|
||||||
|
|
||||||
# discritize attention weights
|
# discritize attention weights
|
||||||
alpha_t = torch.sum(phi_t, 1)
|
alpha_t = torch.sum(phi_t, 1)
|
||||||
|
@ -182,8 +184,6 @@ class GravesAttention(nn.Module):
|
||||||
alpha_t.data.masked_fill_(~mask, self._mask_value)
|
alpha_t.data.masked_fill_(~mask, self._mask_value)
|
||||||
|
|
||||||
context = torch.bmm(alpha_t.unsqueeze(1), inputs).squeeze(1)
|
context = torch.bmm(alpha_t.unsqueeze(1), inputs).squeeze(1)
|
||||||
# for better visualization
|
|
||||||
# self.attention_weights = torch.clamp(alpha_t, min=0)
|
|
||||||
self.attention_weights = alpha_t
|
self.attention_weights = alpha_t
|
||||||
self.mu_prev = mu_t
|
self.mu_prev = mu_t
|
||||||
return context
|
return context
|
||||||
|
|
Loading…
Reference in New Issue