You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a numpy.linalg.LinAlgError: Singular matrix error while using audiomentations==0.39.0. It seems to be related to the Butterworth filter implementation.
Stack Trace
File "/opt/conda/lib/python3.11/site-packages/audiomentations/core/composition.py", line 130, in __call__
samples = transform(samples, sample_rate)
File "/opt/conda/lib/python3.11/site-packages/audiomentations/core/transforms_interface.py", line 139, in __call__
return self.apply(samples, sample_rate)
File "/opt/conda/lib/python3.11/site-packages/audiomentations/augmentations/base_butterword_filter.py", line 227, in apply
sos, samples, zi = sosfilt_zi(sos) * samples[0]
File "/opt/conda/lib/python3.11/site-packages/scipy/signal/_signaltools.py", line 3812, in sosfilt_zi
zi[section] = scale * lfilter_zi(b, a)
File "/opt/conda/lib/python3.11/site-packages/scipy/signal/_signaltools.py", line 3728, in lfilter_zi
zi = np.linalg.solve(IminusA, B)
File "/opt/conda/lib/python3.11/site-packages/numpy/linalg/linalg.py", line 409, in solve
r = gufunc(a, b, signature=signature, extobj=extobj)
File "/opt/conda/lib/python3.11/site-packages/numpy/linalg/linalg.py", line 112, in _raise_linalgerror_singular
raise LinAlgError("Singular matrix")
numpy.linalg.LinAlgError: Singular matrix
Parameters for HighPassFilter hp_min_cutoff=0, hp_max_cutoff=20000
Parameters for LowPassFilter lp_min_cutoff=100000, lp_max_cutoff=150000
sample_rate=384000
Python 3.11
I cannot give exact steps to reproduce as I encountered this issue for the first time after hundreds of training runs, all with the same parameters for Low and HighPassFilter. Also the error occurred in the middle of the training process. My question would be if this is an error that I can avoid through transformation of the audio before passing to the filter, or if it is an error that should be handled by audiomentations.
Let me know if you need further information. Thanks in advance.
Best regards,
Michael
The text was updated successfully, but these errors were encountered:
Thanks for reporting! My first hunch is that it's a bug, and not something wrong with your audio.
I see some interesting facts:
You are using a high sample rate of 384 kHz. This could mean you are using audiomentations in a way that is not yet well tested, although in theory it should just work. Are you working on a bioacoustic application, where ultrasonic frequencies are of importance?
Your hp_min_cutoff=0 is very low, and this could be a source of problems. Try setting it a bit higher, like maybe 1 or 10.
If you have any more information, like how to reproduce this, please share. If not, you could consider adding a try...except in your code, and in the exception handler you can log a few things, like the transform parameters and a few properties of the audio, like duration, standard deviation, min value, max value. That way you can gather information that is useful for narrowing down the issue.
Yes, I am working on bat detection which requires a high sample rate. So far I can say the library works great!
Regarding the error, I set the hp_min_cutoff=10. So far, the error hasn't shown up again. However, as I said it only showed up in one of more than 100 training runs. If I ever run into it again I'll post it with the information you asked.
Error Description
I encountered a
numpy.linalg.LinAlgError: Singular matrix
error while usingaudiomentations==0.39.0
. It seems to be related to the Butterworth filter implementation.Stack Trace
Parameters for HighPassFilter
hp_min_cutoff=0, hp_max_cutoff=20000
Parameters for LowPassFilter
lp_min_cutoff=100000, lp_max_cutoff=150000
sample_rate=384000
Python 3.11
I cannot give exact steps to reproduce as I encountered this issue for the first time after hundreds of training runs, all with the same parameters for Low and HighPassFilter. Also the error occurred in the middle of the training process. My question would be if this is an error that I can avoid through transformation of the audio before passing to the filter, or if it is an error that should be handled by audiomentations.
Let me know if you need further information. Thanks in advance.
Best regards,
Michael
The text was updated successfully, but these errors were encountered: