Apply layer normalization. :param torch.Tensor x: input tensor :return: layer normalized tensor :rtype torch.Tensor
(self, x)
| 46 | self.dim = dim |
| 47 | |
| 48 | def forward(self, x): |
| 49 | """Apply layer normalization. |
| 50 | :param torch.Tensor x: input tensor |
| 51 | :return: layer normalized tensor |
| 52 | :rtype torch.Tensor |
| 53 | """ |
| 54 | if self.dim == -1: |
| 55 | return super(LayerNorm, self).forward(x) |
| 56 | return super(LayerNorm, self).forward(x.transpose(1, -1)).transpose(1, -1) |
| 57 | |
| 58 | |
| 59 | class DurationPredictor(torch.nn.Module): |