Closed SuperKogito closed 5 hours ago
@SuperKogito A few suggestions:
0.1
is a bit too high for Adam to work.a
coefficient to ensure stability. Some reference: https://arxiv.org/abs/2103.08709 (they also used biquad just like your sos
params)@yoyololicon thank you for your response, with low learning rate, stability constraint and bit more fine tuning, I managed to have a stable run and a more smoothly decaying loss.
def forward(self, x):
for layer in self.layers:
x = layer(x)
sos = x
# make sure that a0 = ones
a0 = torch.ones_like(sos[:, :, 0])
# Enforce stability constraint based on https://arxiv.org/pdf/2103.08709 eq. (4, 5)
a1 = 2 * torch.tanh(sos[:, :, 3])
a2 = ((2 - torch.abs(a1)) * torch.tanh(sos[:, :, 4]) + torch.abs(a1)) * 0.5
sos = torch.stack([sos[:, :, 0], sos[:, :, 1], sos[:, :, 2], a0, a1, a2], dim=-1)
return sos
for biquads this seems to work (somewhat). I have one more inquiry regarding the lfilter()
function; in order to use it to compute the output of a cascade of biquads am I supposed to use it in a loop as follows:
class BiquadsCascade(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(x, a, b):
num_biquads = a.shape[0]
for biquad_idx in range(num_biquads):
x = lfilter(x, a[biquad_idx,:], b[biquad_idx,:])
return x
since lfilter expects a filter and not a cascade of biquads. Is there a better way to do this? switching between the cascaded coefficients and high order coefficients using scipy does not seem to a be an option for me since that implementation is probably not differentiable, hence it will hinder the back-propagation
You can reference this implementation to combine multiple biquads into one high-order filter. https://github.com/yoyololicon/golf/blob/52f50e7341f769d49e6bddbbe887c149c2b9a413/models/utils.py#L444-L460
Note: The above code only handles the poles (denominator of the transfer function), but the function can also be applied to zeros.
This looks very helpful. Thank you :)
🐛 Describe the bug
🐛 Describe the bug
When trying to use
torchaudio.functional.lfilter
to generate training data,lfilter
works as expected. However, when using it in the loss computation is returns a bunch ofnan
values in the prediction causing my loss to becomenan
.Code
Output
Usually it takes some iterations for the nan values to show up but I am not sure why this happens? could this be floating point error as I am using floats and not double ?
On the other hand, when I use a smaller sequence_length, the error either does not happen or takes longer to happen. However in all case my gradient is None, which I think making the code does not converge/ work as it is supposed to
Versions