Keras fitting ignoring nan values
<p>I am training a neural network to do regression, (1 input and 1 output). Let's <code>x</code> and <code>y</code> be the usual input and output dataset, respectively.</p>

<p>My problem is that the <code>y</code> dataset (not the <code>x</code>) have some values set to nan, so the fitting goes to nan. I wonder if there is an option to ignore the nan values in the fitting, in a similar way to the numpy functions <code>np.nanmean</code> to calculate the mean ignoring nans and so on.</p>

<p>If that option does not exist I suppose I would have to find the nan values and erase them manually, <strong>and at the same time</strong> erase the values in <code>x</code> corresponding to the nan position in <code>y</code>. </p>

<pre><code>x       y
2       4
3       2
4      np.nan
5       7
6      np.nan
7      np.nan
</code></pre>

<p>In this simple example the nan values in the y column should be removed and at the same time the corresponding values in the x column (4, 6, 7).</p>

<p>Thank you.</p>

<p><strong>EDIT:</strong> Ok, I have a problem filtering the nans, I do:</p>

<pre><code>for index, x in np.ndenumerate(a):
    if x == np.nan:
        print index, x
</code></pre>

<p>and it doesn't print anything and I am sure there are nan values...</p>

<p><strong>EDIT (SELF ANSWER):</strong> Ok, I have found a way to localize the nans:</p>

<pre><code>for index, x in np.ndenumerate(a):
      if x != x:
           print index, x
</code></pre>