sentence-similarity.py 文件源码

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

项目:visually-grounded-speech 作者: gchrupala 项目源码 文件源码
def cosine_similarities(a, b, transform):
    """
    returns list of cosine similarities between lists of vectors
    a and b. The z_score transformation is applied if transform == True
    """
    a = numpy.stack(a)
    b = numpy.stack(b)
    #transform if requested
    if transform:
        print "transforming"
        # z_score is written to apply same scale to a and b
        a, b = z_score(a, b)
    print "calculating cosine dists"
    cos = [cosine_similarity(a[i], b[i]) for i in range(len(a))]
    return cos
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号