MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / LayerNorm

Class LayerNorm

modules/fastspeech/tts_modules.py:37–56  ·  view source on GitHub ↗

Layer normalization module. :param int nout: output dim size :param int dim: dimension to be normalized

Source from the content-addressed store, hash-verified

35# fastspeech modules
36######################
37class LayerNorm(torch.nn.LayerNorm):
38 """Layer normalization module.
39 :param int nout: output dim size
40 :param int dim: dimension to be normalized
41 """
42
43 def __init__(self, nout, dim=-1):
44 """Construct an LayerNorm object."""
45 super(LayerNorm, self).__init__(nout, eps=1e-12)
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
59class DurationPredictor(torch.nn.Module):

Callers 3

__init__Method · 0.70
__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected