def make_dense(targets, noclass):
 with tf.device('/cpu:0'):
  shape = tf.shape(targets)
  batch_size = shape[0]
  indices = (targets + (noclass * tf.range(0, batch_size)))
  length = tf.expand_dims((batch_size * noclass), 0)
  dense = tf.sparse_to_dense(indices, length, 1.0, 0.0)
 return tf.reshape(dense, [(-1), noclass])

def make_dense ( targets , noclass ) : with tf . device ( '/cpu:0' ) : shape = tf . shape ( targets ) batch_size = shape [ 0 ] indices = ( targets + ( noclass * tf . range ( 0 , batch_size ) ) ) length = tf . expand_dims ( ( batch_size * noclass ) , 0 ) dense = tf . sparse_to_dense ( indices , length , 1.0 , 0.0 ) return tf . reshape ( dense , [ ( - 1 ) , noclass ] )
move a batch of targets to a dense 1-hot representation .