tf.keras.backend.one_hot

View source on GitHub

Computes the one-hot representation of an integer tensor.

tf.keras.backend.one_hot(
    indices, num_classes
)

Arguments:

Returns:

(n + 1)D one hot representation of the input with shape (batch_size, dim1, dim2, ... dim(n-1), num_classes)

Returns:

The one-hot tensor.