inputs.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:text-classification2 作者: yuhui-lin 项目源码 文件源码
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])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号