1

I encountered " RuntimeWarning: overflow encountered in exp " while implementing Sigmoid in my code.

I tried to solved it by using this solution sigmoid RuntimeWarning: overflow encountered in exp .
Nonetheless, now a new error occurs on the if-condition.

Here the code that I tried:

class Sigmoid:
    @staticmethod
    def activation(x):
        if -x > np.log(np.finfo(type(x)).max):
            return 0.0
        a = np.exp(-x)
        return 1.0 / (1.0 + a)

So this error arises:

File "/MyPathCode/", line 14 in activation
   if -x > np.log(np.finfo(type(x)).max):
File "/home/UserName/.local/lib/python3.6/site-packages/numpy/core/getlimits.py", line 381, in __new__
    raise ValueError("data type %r not inexact" % (dtype))
ValueError: data type <class 'numpy.object_'> not inexact
desertnaut
  • 57,590
  • 26
  • 140
  • 166
user5431233
  • 61
  • 1
  • 8

0 Answers0