Skip to content
masterclass Buddy

TensorFlow · Class

losses.SparseCategoricalCrossentropy

Computes crossentropy for classification labels stored as integer class IDs. Use it when predictions contain one value per class and labels are not one-hot encoded.

Last updated

Syntax

tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False, ignore_class=None, reduction="sum_over_batch_size", axis=-1, name="sparse_categorical_crossentropy", dtype=None)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • tf.keras.losses.CategoricalCrossentropy
  • tf.keras.losses.Loss

Source: tf.keras.losses.SparseCategoricalCrossentropy | TensorFlow v2.21.0. Checked 2026-11-03.