tf.keras.losses.SparseCategoricalCrossentropy

Computes the crossentropy loss between the labels and predictions.

Inherits From: Loss

Used in the notebooks

Used in the guide Used in the tutorials

Use this crossentropy loss function when there are two or more label classes. We expect labels to be provided as integers. If you want to provide labels using one-hot representation, please use CategoricalCrossentropy loss. There should be # classes floating point values per feature for y_pred and a single floating point value per feature for y_true.

In the snippet below, there is a single floating point value per example for y_true and # classes floating pointing values per example for y_pred. The shape of y_true is [batch_size]