我希望深度可以是一个张量,这就是结果:
indices = [0,1,2],depth = [4,1,2]
tf.one_hot(指数,深度)
结果:[[4.,0.,0。],[0,1。,0。],[0.,0.,2。]]
答案 0 :(得分:0)
好吧,我最终解决了它:
A = tf.placeholder(tf.int32, shape=[4])
depth = tf.placeholder(tf.int32, shape=[4])
oneHots = tf.one_hot(A, 4, dtype=tf.int32)
result = tf.multiply(oneHots,tf.transpose(depth))