def check_embed_match(X_embed1, X_embed2):
"""
Check whether the two embeddings are almost the same by computing their normalized euclidean distances
in the embedding space and checking the correlation.
Inputs:
- X_embed1, X_embed2: two Nxd matrices with coordinates in the embedding space
Returns:
- r: Pearson correlation coefficient between the normalized distances of the points
"""
D_emb1 = pdist(X_embed1, 'euclidean')
D_emb2 = pdist(X_embed2, 'euclidean')
D_emb1 /= D_emb1.max()
D_emb2 /= D_emb2.max()
return np.corrcoef(D_emb1, D_emb2)[0, 1]
评论列表
文章目录