-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【Hackathon 8th No.9】在 PaddleSpeech 中复现 DAC 训练需要用到的 loss #3954
base: develop
Are you sure you want to change the base?
Conversation
Thanks for your contribution! |
In the original DAC repository, the training data is generated randomly. To assess accuracy, I sampled ten loss values and saved them in PyTorch tensor (.pt) format. The original repository showed no numerical errors, but in the Paddle implementation, bias is observed and I still tracing it . Here is the test result
|
With these patch, the new test result is below diff --git a/paddlespeech/t2s/modules/losses.py b/paddlespeech/t2s/modules/losses.py
index 029ad1be..ce5f441d 100644
--- a/paddlespeech/t2s/modules/losses.py
+++ b/paddlespeech/t2s/modules/losses.py
@@ -501,7 +502,7 @@ def stft(x,
real = x_stft.real()
imag = x_stft.imag()
- return paddle.sqrt(paddle.clip(real**2 + imag**2, min=1e-7)).transpose(
+ return paddle.clip(paddle.sqrt(real**2 + imag**2), min=clamp_eps).transpose(
[0, 2, 1])
@@ -930,7 +930,7 @@ class MelSpectrogram(nn.Layer):
real = real.transpose([0, 2, 1])
imag = imag.transpose([0, 2, 1])
x_power = real**2 + imag**2
- x_amp = paddle.sqrt(paddle.clip(x_power, min=self.eps))
+ x_amp = paddle.clip(paddle.sqrt(x_power), min=self.eps)
|
开发者你好,感谢你的参与!由于你的黑客松赛题完成度较高,其PR已被锁定,请尽快完善锁定的PR,并确保在2025年1月3日前完成合入。逾期未合入PR将无法获得奖金发放。 |
…ust the clipping threshold
…n calculation methods - Change precision threshold to ’1e-5‘ - Use relative error instead of absolute error
📢:请尽快完善锁定的PR,并确保在2025年1月10日(不再延期)前完成合入。逾期未合入PR将无法获得奖金发放。 |
|
||
import librosa | ||
import numpy as np | ||
import paddle | ||
from paddle import nn | ||
from paddle.nn import functional as F | ||
from paddleaudio.audiotools import AudioSignal | ||
from paddleaudio.audiotools import STFTParams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
miss SISDRLoss?
loss_1.backward() | ||
loss_1_grad = signal.audio_data.grad.sum() | ||
|
||
assert abs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest use np.testing.assert_allclose
, these losses can pass 1e-6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently not. After debugging, I find out that the loss is generated by 'paddle.signal.stft' (without cuda), so I have to compare the implement with '_VF' and paddle. I'm sure that the loss can decrease to 0 if fixing this
PR types
New features
PR changes
APIs
Describe