# tf.keras.backend.one_hot

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/backend/one_hot) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/backend.py#L3215-L3231) |

Computes the one-hot representation of an integer tensor.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.keras.backend.one_hot`](https://www.tensorflow.org/api_docs/python/tf/keras/backend/one_hot)

<br />

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

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `indices` | nD integer tensor of shape `(batch_size, dim1, dim2, ... dim(n-1))` |
| `num_classes` | Integer, number of classes to consider. |

<br />

<br />

<br />

<br />

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

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The one-hot tensor. ||

<br />