title: sigmoid RuntimeWarning: overflow encountered in exp
body: <p>I'm trying to create a sigmoid function in Python, however, I get the following error:</p>
  
  <pre><code>RuntimeWarning: overflow encountered in exp
  </code></pre>
  
  <p>Here my code:</p>
  
  <pre><code>def sigmoid(self, value):
  
      a = np.exp(-value)
      return 1.0/ (1.0 + a)
  </code></pre>
  
  <p>I searched for previous answers, but they didn't solve my problem.
  The problem is on calculating the value of a.
  I also tried using:</p>
  
  <p><code>a = np.float128(np.exp(-value))</code></p>
  
  <p>but I got the same error, and using:</p>
  
  <p><code>a = np.float256(np.exp(-value))</code></p>
  
  <p>I got the following error:</p>
  
  <pre><code>AttributeError: 'module' object has no attribute 'float256'
  </code></pre>
  
  <p>I thought that if I have an overflow I could return 0, and if I have an underflow I could return 1</p>