tensorflow2.X转换Onehot

1
2
3
4
5
6
7
8
9
import tensorflow as tf 


x = tf.constant([1,5,9,0])
x_onehot = tf.one_hot(x,depth=10)


print(x)
print(x_onehot)

转载请注明来源 https://tianweiye.github.io