loss.py 文件源码

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

项目:tensorflow-layer-library 作者: bioinf-jku 项目源码 文件源码
def one_hot_patch(x, depth):
    # workaround by name-name
    sparse_labels = tf.reshape(x, [-1, 1])
    derived_size = tf.shape(sparse_labels)[0]
    indices = tf.reshape(tf.range(0, derived_size, 1), [-1, 1])
    concated = tf.concat(axis=1, values=[indices, sparse_labels])
    outshape = tf.concat(axis=0, values=[tf.reshape(derived_size, [1]), tf.reshape(depth, [1])])
    return tf.sparse_to_dense(concated, outshape, 1.0, 0.0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号