Spaces:
Running
Running
update
Browse files
toolbox/torchaudio/losses/spectral.py
CHANGED
@@ -184,6 +184,11 @@ class SpectralConvergenceLoss(torch.nn.Module):
|
|
184 |
raise AssertionError("SpectralConvergenceLoss, inf in truth_norm")
|
185 |
|
186 |
batch_loss = error_norm / truth_norm
|
|
|
|
|
|
|
|
|
|
|
187 |
if self.reduction == "mean":
|
188 |
loss = torch.mean(batch_loss)
|
189 |
elif self.reduction == "sum":
|
|
|
184 |
raise AssertionError("SpectralConvergenceLoss, inf in truth_norm")
|
185 |
|
186 |
batch_loss = error_norm / truth_norm
|
187 |
+
if torch.any(torch.isnan(batch_loss)):
|
188 |
+
raise AssertionError("SpectralConvergenceLoss, nan in batch_loss")
|
189 |
+
if torch.any(torch.isinf(batch_loss)):
|
190 |
+
raise AssertionError("SpectralConvergenceLoss, inf in batch_loss")
|
191 |
+
|
192 |
if self.reduction == "mean":
|
193 |
loss = torch.mean(batch_loss)
|
194 |
elif self.reduction == "sum":
|