python - invalid value encountered in log : <p>I have the following expression:
<code>log = np.sum(np.nan_to_num(-y*np.log(a+ 1e-7)-(1-y)*np.log(1-a+ 1e-7)))</code></p>

<p>it is giving me the following warning:</p>

<pre><code>RuntimeWarning: invalid value encountered in log
  log = np.sum(np.nan_to_num(-y*np.log(a+ 1e-7)-(1-y)*np.log(1-a+ 1e-7)))
</code></pre>

<p>I don't understand what might be the invalid value or why am I getting it. Any and every help is appreciated.</p>

<p><strong>NOTE</strong>: This is a cross-entropy cost function where I added <code>1e-7</code> to avoid having zeros inside log. <code>y</code> &amp; <code>a</code> are numpy arrays and <code>numpy</code> is imported as <code>np</code>.</p>
