title: Keras - Difference between categorical_accuracy and sparse_categorical_accuracy
body: <p>What is the difference between <code>categorical_accuracy</code> and <code>sparse_categorical_accuracy</code> in Keras? There is no hint in the <a href="https://keras.io/metrics/" rel="noreferrer">documentation for these metrics</a>, and by asking Dr. Google, I did not find answers for that either.</p>
  
  <p>The source code can be found <a href="https://github.com/fchollet/keras/blob/master/keras/metrics.py" rel="noreferrer">here</a>:</p>
  
  <pre><code>def categorical_accuracy(y_true, y_pred):
      return K.cast(K.equal(K.argmax(y_true, axis=-1),
                            K.argmax(y_pred, axis=-1)),
                    K.floatx())
  
  
  def sparse_categorical_accuracy(y_true, y_pred):
      return K.cast(K.equal(K.max(y_true, axis=-1),
                            K.cast(K.argmax(y_pred, axis=-1), K.floatx())),
                    K.floatx())
  </code></pre>