def char_index_batch_to_2d_tensor(batch, batch_size, num_labels):
sparse_labels = tf.reshape(batch, [batch_size, 1])
indices = tf.reshape(tf.range(0, batch_size, 1), [batch_size, 1])
concatenated = tf.concat(1, [indices, sparse_labels])
concat = tf.concat(0, [[batch_size], [num_labels]])
output_shape = tf.reshape(concat, [2])
sparse_to_dense = tf.sparse_to_dense(concatenated, output_shape, 1, 0)
return tf.reshape(sparse_to_dense, [batch_size, num_labels])
评论列表
文章目录