Convert a tensor string label to one hot encoding

def to_one_hot(image,label):
return image,tf.one_hot(classes_to_indices[label],depth=14)

train_ds =

calsses_to_indices is a simple python dictionary containing { label_name: indices }

this code is showing an error:-
Tensor is unhashable. Instead, use tensor.ref() as the key.

is there any way to do one_hot encoding while using API ?

Can you check:

Ya, I have checked it but it is for NumPy data. I want to convert my string labels to integer labels using python dictionary calsses_to_indices but we cannot use tensor data in the python dictionary.

Is that dataset Map transforms are executed in graph mode.

More details at: