similarities.py 文件源码

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

项目:How-to-Learn-from-Little-Data 作者: llSourcell 项目源码 文件源码
def cosine_similarity(x, y, eps=1e-6):
    z = tf.batch_matmul(x, tf.transpose(y, perm=[0,2,1]))
    z /= tf.sqrt(tf.multiply(tf.expand_dims(tf.reduce_sum(tf.multiply(x,x), 2), 2),tf.expand_dims(tf.reduce_sum(tf.multiply(y,y), 2), 1)) + eps)

    return z
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号