title: Sparse categorical entropy loss becomes NaN without label encoding
body: <p>I'm building a classifier for predicting labels -1 and 1. When I encode the labels by one hot encoder and use categorical cross entropy, I don't have any problems with learning.</p>
  <pre><code>model1.add(Dense(2, activation='softmax'))
  model1.compile(loss='categorical_crossentropy', optimizer=optim, metrics=['accuracy'])
  </code></pre>
  <p>When I keep the labels without encoding and try to use sparse categorical cross entropy, the model loss is NaN.</p>
  <pre><code>model1.add(Dense(2, activation='softmax'))
  model1.compile(loss='sparse_categorical_crossentropy', optimizer=optim, metrics=['accuracy'])
  
  Epoch 1/3000
  20748/20748 [==============================] - 2s 78us/sample - loss: nan - accuracy: 0.0000e+00 - val_loss: nan - val_accuracy: 0.0000e+00
  </code></pre>
  <p>When I encode the labels with ordinal encoder to be 0,1 instead -1,1 and train the model with sparse categorical entropy, the model doesn't show this problem with loss.</p>
  <p>What is the reason for such a problem? I read that training with symmetrical labels around 0 is a problem but what is the explanation for that?</p>
  <p>I know my Problem is binary classification but I wanted to test my model on binary data before using it for all labels</p>