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

Method forward

modules/parallel_wavegan/losses/stft_loss.py:89–106  ·  view source on GitHub ↗

Calculate forward propagation. Args: x (Tensor): Predicted signal (B, T). y (Tensor): Groundtruth signal (B, T). Returns: Tensor: Spectral convergence loss value. Tensor: Log STFT magnitude loss value.

(self, x, y)

Source from the content-addressed store, hash-verified

87 self.log_stft_magnitude_loss = LogSTFTMagnitudeLoss()
88
89 def forward(self, x, y):
90 """Calculate forward propagation.
91
92 Args:
93 x (Tensor): Predicted signal (B, T).
94 y (Tensor): Groundtruth signal (B, T).
95
96 Returns:
97 Tensor: Spectral convergence loss value.
98 Tensor: Log STFT magnitude loss value.
99
100 """
101 x_mag = stft(x, self.fft_size, self.shift_size, self.win_length, self.window)
102 y_mag = stft(y, self.fft_size, self.shift_size, self.win_length, self.window)
103 sc_loss = self.spectral_convergenge_loss(x_mag, y_mag)
104 mag_loss = self.log_stft_magnitude_loss(x_mag, y_mag)
105
106 return sc_loss, mag_loss
107
108
109class MultiResolutionSTFTLoss(torch.nn.Module):

Callers

nothing calls this directly

Calls 1

stftFunction · 0.85

Tested by

no test coverage detected