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

Class Stretch2d

modules/parallel_wavegan/layers/upsample.py:16–44  ·  view source on GitHub ↗

Stretch2d module.

Source from the content-addressed store, hash-verified

14
15
16class Stretch2d(torch.nn.Module):
17 """Stretch2d module."""
18
19 def __init__(self, x_scale, y_scale, mode="nearest"):
20 """Initialize Stretch2d module.
21
22 Args:
23 x_scale (int): X scaling factor (Time axis in spectrogram).
24 y_scale (int): Y scaling factor (Frequency axis in spectrogram).
25 mode (str): Interpolation mode.
26
27 """
28 super(Stretch2d, self).__init__()
29 self.x_scale = x_scale
30 self.y_scale = y_scale
31 self.mode = mode
32
33 def forward(self, x):
34 """Calculate forward propagation.
35
36 Args:
37 x (Tensor): Input tensor (B, C, F, T).
38
39 Returns:
40 Tensor: Interpolated tensor (B, C, F * y_scale, T * x_scale),
41
42 """
43 return F.interpolate(
44 x, scale_factor=(self.y_scale, self.x_scale), mode=self.mode)
45
46
47class Conv2d(torch.nn.Conv2d):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected