Tensorflow One Hot Encoder ?
In Tensorflow, the tf.one_hot() is easy to use.
Here, the depth=4 and indices=[0, 3]
import tensorflow as tf res = tf.one_hot(indices=[0, 3], depth=4) with tf.Session() as sess: print sess.run(res)
Note that when you provide index=-1 it will get all zeros in your one-hot vector