keras - why I getting nan at output?
<p>About task : I have class distances as input and want to get class confidences (number between 0.0 and 1.0).
So I have something like :</p>

<pre><code>[
  [
    0.0,
    0.0,
    0.0,
    6.371921190238224,
    0.0,
    3.3287083713830516,
    7.085957828217146,
    7.747408965761948,
    5.498717498872398,
    5.498717498872398,
    5.498717498872398,
    5.498717498872398,
    8.529725281060978
  ],
  [
    6.396501448825533,
    0.0,
    0.0,
    5.217483270813266,
    0.0,
    5.319046151560534,
    5.823161030197735,
    3.8991256371824976,
    6.269856323952211,
    5.517874167220461,
    6.396501448825533,
    5.328678274963717,
    3.8991256371824976
  ],
]
</code></pre>

<p>And as result</p>

<pre><code>[
  [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
  [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
  ...
]
</code></pre>

<p>I have about 200 examples. My network building code is next :</p>

<pre><code>def train(self, distances, classes):
    """
    Train network
    :param distances: array of distances to classes
    :type distances: list[list[float]]
    :param classes: array of class indicators
    :type classes: list[list[float]]
    """
    example_count, class_count = self._dimensions(distances, classes)
    self.model = Sequential()
    self.model.add(Dense(128, input_dim=class_count))
    self.model.add(Dense(class_count))
    self.model.compile(optimizer=SGD(), loss='mse')
    self.model.fit(array(distances), array(classes))
</code></pre>

<p>But during training I get next output :</p>

<pre><code>Epoch 1/10
425/425 [==============================] - 0s - loss: nan     
Epoch 2/10
425/425 [==============================] - 0s - loss: nan     
Epoch 3/10
425/425 [==============================] - 0s - loss: nan     
Epoch 4/10
425/425 [==============================] - 0s - loss: nan     
Epoch 5/10
425/425 [==============================] - 0s - loss: nan     
Epoch 6/10
425/425 [==============================] - 0s - loss: nan     
Epoch 7/10
425/425 [==============================] - 0s - loss: nan     
Epoch 8/10
425/425 [==============================] - 0s - loss: nan     
Epoch 9/10
425/425 [==============================] - 0s - loss: nan     
Epoch 10/10
425/425 [==============================] - 0s - loss: nan    
</code></pre>

<p>And when I trying to use <code>model.predict(numpy.array([[ 0.0, 0.0, 0.0, 6.371921190238224,             0.0, 3.3287083713830516, 7.085957828217146, 7.747408965761948,             5.498717498872398, 5.498717498872398, 5.498717498872398, 5.498717498872398, 8.529725281060978]]))</code> (example from train set) - I getting <code>[[ nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan  nan]]</code></p>

<p>What can be wrong in data or building code?</p>