Perm. Questiin
Perm. Questiin

Reputation: 429

How to tell where my code gives an exp overflow, in numpy?

I keep getting this error when using numpy:

Warning (from warnings module):
  File "somepath.py", line 249
    return 1 / ( 1 + np.exp( -x))
RuntimeWarning: overflow encountered in exp

However this doesn't tell me anything, as I still have no idea how it got to this error. Usually when I get an error it traces back through the functions it went through to get to the error, but not with exp overflow.

How do I get an error in which it does show me this?

Upvotes: 1

Views: 180

Answers (1)

Stephen Rauch
Stephen Rauch

Reputation: 49794

You can ask Python to turn the warning into an error:

import warnings    
warnings.filterwarnings("error", category=RuntimeWarning)

(Docs)

Upvotes: 2

Related Questions