FloatingPointError: underflow encountered in square
See original GitHub issueIt only happens in some audios, but it occurs frequently. And it happens not only in just one function, but many functions like librosa.beat.beat_track() and librosa.feature.mfcc(). Below is an example of librosa.beat.beat_track().
---> 14 tempo, base_beats = librosa.beat.beat_track(y=base, sr=44100)
File \anaconda\lib\site-packages\librosa\util\decorators.py:88, in deprecate_positional_args.<locals>._inner_deprecate_positional_args.<locals>.inner_f(*args, **kwargs)
86 extra_args = len(args) - len(all_args)
87 if extra_args <= 0:
---> 88 return f(*args, **kwargs)
90 # extra_args > 0
91 args_msg = [
92 "{}={}".format(name, arg)
93 for name, arg in zip(kwonly_args[:extra_args], args[-extra_args:])
94 ]
File \anaconda\lib\site-packages\librosa\beat.py:181, in beat_track(y, sr, onset_envelope, hop_length, start_bpm, tightness, trim, bpm, prior, units)
172 bpm = tempo(
173 onset_envelope=onset_envelope,
174 sr=sr,
(...)
177 prior=prior,
178 )[0]
180 # Then, run the tracker
--> 181 beats = __beat_tracker(onset_envelope, bpm, float(sr) / hop_length, tightness, trim)
183 if units == "frames":
184 pass
File \anaconda\lib\site-packages\librosa\beat.py:599, in __beat_tracker(onset_envelope, bpm, fft_res, tightness, trim)
596 beats = np.array(beats[::-1], dtype=int)
598 # Discard spurious trailing beats
--> 599 beats = __trim_beats(localscore, beats, trim)
601 return beats
File \anaconda\lib\site-packages\librosa\beat.py:682, in __trim_beats(localscore, beats, trim)
679 smooth_boe = scipy.signal.convolve(localscore[beats], scipy.signal.hann(5), "same")
681 if trim:
--> 682 threshold = 0.5 * ((smooth_boe ** 2).mean() ** 0.5)
683 else:
684 threshold = 0.0
FloatingPointError: underflow encountered in square
version: 0.9.1
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Numpy error: underflow encountered in exp - Stack Overflow
FloatingPointError : underflow encountered in exp. The array I'm trying to define is as follows: time = np.arange(length) window ...
Read more >What is the significance of underflow during parameter update ...
Underflow is happening because the result of that calculation is a number of smaller absolute value than your computer can actually ...
Read more >Log Scale: FloatingPointError: underflow encountered in ...
When plotting data beforehand, everything works fine. This is an issue for me, because I'm trying to plot multiple subplots with shared y...
Read more >numpy.seterr — NumPy v1.25.dev0 Manual
Underflow: result so close to zero that some precision was lost. ... line 1, in <module> FloatingPointError: overflow encountered in scalar multiply.
Read more >How to Fix: RuntimeWarning: Overflow encountered in exp
This warning occurs while using the NumPy library's exp() function upon using on a value that is too large.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve changed my numpy configuration and now it works. Thank you!
I’ve been unable to replicate this so far. I’m attempting the following:
which is designed to underflow float32 precision. It does not ever trigger the exception above. Here’s my configuration:
@weWillGetThere one thing that might be relevant here is the numpy error configuration. Can you run
np.geterr()
in your environment and report the result? For my installation, I have:My guess is that your configuration might have
'under': 'raise'
. If my guess is correct, then there’s nothing really for us to do here. The underflow is expected in this case, and ought to be harmless, so you could (temporarily) donp.seterr(under='ignore')
(or warn, or whatever) to avoid this issue.