title: implement N-hot encoding in tf.slim
body: <p>How to implement N-hot encoding according to the index of 1 in a tf.int64 ? The input is tensor containing several tf.int64. The N-hot encoding is aimed to replace one-hot encoding in tf.slim.</p>
  
  <p>The one_hot encoding is implemented as following:</p>
  
  <pre><code>def dense_to_one_hot(labels_dense, num_classes):
    """Convert class labels from scalars to one-hot vectors."""
    num_labels = labels_dense.shape[0]
    index_offset = numpy.arange(num_labels) * num_classes
    labels_one_hot = numpy.zeros((num_labels, num_classes))
    labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
    return labels_one_hot
  </code></pre>
  
  <p>The N-not encoding means: 19=00010011, the result after encoding is [0,0,0,1,0,0,1,1].</p>