LostTech.TensorFlow : API Documentation

Type SparseCategoricalCrossentropy

Namespace tensorflow.keras.losses

Parent LossFunctionWrapper

Interfaces ISparseCategoricalCrossentropy

Computes the crossentropy loss between the labels and predictions.

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]` and the shape of `y_pred` is `[batch_size, num_classes]`.

Usage: Usage with the `compile` API:
Show Example
cce = tf.keras.losses.SparseCategoricalCrossentropy()
            loss = cce(
              tf.convert_to_tensor([0, 1, 2]),
              tf.convert_to_tensor([[.9,.05,.05], [.5,.89,.6], [.05,.01,.94]]))
            print('Loss: ', loss.numpy())  # Loss: 0.3239 

Properties

Public properties

object fn get; set;

string name get; set;

object PythonObject get;

string reduction get; set;