| 70 | |
| 71 | |
| 72 | class AdaLayerNorm(nn.Module): |
| 73 | def __init__(self, style_dim, channels, eps=1e-5): |
| 74 | super().__init__() |
| 75 | self.channels = channels |
| 76 | self.eps = eps |
| 77 | self.fc = nn.Linear(style_dim, channels*2) |
| 78 | |
| 79 | def forward(self, x, s): |
| 80 | x = x.transpose(-1, -2) |
| 81 | x = x.transpose(1, -1) |
| 82 | h = self.fc(s) |
| 83 | h = h.view(h.size(0), h.size(1), 1) |
| 84 | gamma, beta = torch.chunk(h, chunks=2, dim=1) |
| 85 | gamma, beta = gamma.transpose(1, -1), beta.transpose(1, -1) |
| 86 | x = F.layer_norm(x, (self.channels,), eps=self.eps) |
| 87 | x = (1 + gamma) * x + beta |
| 88 | return x.transpose(1, -1).transpose(-1, -2) |
| 89 | |
| 90 | |
| 91 | class ProsodyPredictor(nn.Module): |