One-hot encoding (OHE) is where a tensor is constructed from the data labels with a 1 in each of the elements corresponding to a label's value, and 0 everywhere else; that is, one of the bits in the tensor is hot (1).
One-hot encoding
OHE example 1
In this example, we are converting a decimal value of 5 to a one-hot encoded value of 0000100000 using the tf.one_hot() method:
y = 5
y_train_ohe = tf.one_hot(y, depth=10).numpy()
print(y, "is ",y_train_ohe,"when one-hot encoded with a depth of 10")
# 5 is 00000100000 when one-hot encoded with a depth of 10