samediff.py 文件源码

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

项目:Multi-view-neural-acoustic-words-embeddings 作者: opheadacheh 项目源码 文件源码
def generate_matches_array(labels):
    """
    Return an array of bool in the same order as the distances from
    `scipy.spatial.distance.pdist` indicating whether a distance is for
    matching or non-matching labels.
    """
    N = len(labels)
    matches = np.zeros(N * (N - 1) / 2, dtype=np.bool)

    # For every distance, mark whether it is a true match or not
    cur_matches_i = 0
    for n in range(N):
        cur_label = labels[n]
        matches[cur_matches_i:cur_matches_i + (N - n) - 1] = np.asarray(labels[n + 1:]) == cur_label
        cur_matches_i += N - n - 1

    return matches
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号