tf.one_hot is one of the functions which can convert a set of sparse labels to a dense one-hot representation, as of TensorFlow 0.8. In some cases, tf.nn.sparse_softmax_cross_entropy_with_logits can be used to calculate cross-entropy directly on sparse labels instead of converting them to one-hot.In case you want to to do in the old primitive way refer to the following code which uses sparse-to-dense operator:

numLabel = 10

sprsLabel= tf.reshape(lBatch, [-1, 1])

deriveSize = tf.shape(lbatch)[0]

i = tf.reshape(tf.range(0, deriveSize, 1), [-1, 1])

conc = tf.concat(1, [i, sprsLabel])

outshape = tf.pack([deriveSize, numLabel])

labels = tf.sparse_to_dense(conc, outshape, 1.0, 0.0)

This gives a label as an output which is a one-hot matric having a size equal to batchsize x numLabel.

Hope this answer helps.

If you want to get professional experience in TensorFlow, join this Machine Learning Course.