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

Method __init__

modules/fastspeech/tts_modules.py:193–220  ·  view source on GitHub ↗

Initilize pitch predictor module. Args: idim (int): Input dimension. n_layers (int, optional): Number of convolutional layers. n_chans (int, optional): Number of channels of convolutional layers. kernel_size (int, optional): Kernel size of conv

(self, idim, n_layers=5, n_chans=384, odim=2, kernel_size=5,
                 dropout_rate=0.1, padding='SAME')

Source from the content-addressed store, hash-verified

191
192class PitchPredictor(torch.nn.Module):
193 def __init__(self, idim, n_layers=5, n_chans=384, odim=2, kernel_size=5,
194 dropout_rate=0.1, padding='SAME'):
195 """Initilize pitch predictor module.
196 Args:
197 idim (int): Input dimension.
198 n_layers (int, optional): Number of convolutional layers.
199 n_chans (int, optional): Number of channels of convolutional layers.
200 kernel_size (int, optional): Kernel size of convolutional layers.
201 dropout_rate (float, optional): Dropout rate.
202 """
203 super(PitchPredictor, self).__init__()
204 self.conv = torch.nn.ModuleList()
205 self.kernel_size = kernel_size
206 self.padding = padding
207 for idx in range(n_layers):
208 in_chans = idim if idx == 0 else n_chans
209 self.conv += [torch.nn.Sequential(
210 torch.nn.ConstantPad1d(((kernel_size - 1) // 2, (kernel_size - 1) // 2)
211 if padding == 'SAME'
212 else (kernel_size - 1, 0), 0),
213 torch.nn.Conv1d(in_chans, n_chans, kernel_size, stride=1, padding=0),
214 torch.nn.ReLU(),
215 LayerNorm(n_chans, dim=1),
216 torch.nn.Dropout(dropout_rate)
217 )]
218 self.linear = torch.nn.Linear(n_chans, odim)
219 self.embed_positions = SinusoidalPositionalEmbedding(idim, 0, init_size=4096)
220 self.pos_embed_alpha = nn.Parameter(torch.Tensor([1]))
221
222 def forward(self, xs):
223 """

Callers

nothing calls this directly

Calls 3

LayerNormClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected