Py3代码:
# one-hot 函数的样例
import tensorflow as tf
label = tf.placeholder(tf.int32,[None])
# 直接把 输入的序列进行One-Hot的结果
one_hot = tf.one_hot(label, 3, 1, 0)
# 进行转置
one_hot_new = tf.transpose(one_hot, perm=[1,0])
one_hot_new = tf.cast(one_hot_new, tf.float32)
# one_hot_new[2] = one_hot_new[2] * 1.5
# 按照每两维的大小进行拆分
one_hot_new_1 = tf.dynamic_partition(one_hot_new, [0, 0, 1],