Home>

TensorFlow tutorial didn't understand. The part that I don't understand is the classification of the first one,

model.compile (optimizer = tf.train.AdamOptimizer (),
              loss = 'sparse_categorical_crossentropy',
              metrics = ['accuracy'])


Sparse_categorical_crossentropy.
This code is later

model.fit (train_images, train_labels, epochs = 5)


Is executed, but since the last layer of the model uses a softmax function, the predicted value is two-dimensional. However, sparse_categorical_crossentropy supports sparse labels. Why is this going to work? sparse_categorical_crossentropy specifies only the dimension of the correct label, and I guess that the prediction can be either 2D or 1D ... Thanks for your answer.

  • Answer # 1

    If you look at the Keras tutorial, it looks like you are looking at the dimension of the target value, not the output value.

Related articles