NaN from sparse_softmax_cross_entropy_with_logits in Tensorflow

It actually turns out that some of my labels were out of range (e.g. a label of 14000, when my logits matrix is just 150 x 10000). It turns out this results in a NaN rather than an error.


tf.sparse_softmax_cross_entropy_with_logits handles the case of log(0) for you, you don't have to worry about it.

Usually a NaN is due to a high learning rate of your optimization algorithm. Try to lower it until NaN errors disappear and the loss starts to decrease