Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问原作者的论文中提到的余弦相似度计算距离,为什么在您的代码中找不到在哪里实现的呢? #4

Open
HongTao-Yu opened this issue Jul 21, 2021 · 2 comments

Comments

@HongTao-Yu
Copy link

请问原作者的论文中提到的余弦相似度计算距离,为什么在您的代码中找不到在哪里实现的呢?

@HongtaoYang
Copy link
Owner

HongtaoYang commented Jul 21, 2021

在这里:

sim_mat = tf.matmul(label_feat_norm, label_feat_norm, transpose_b=True)

余弦相似度等价于两个 l2-normalized 向量的点积。这里用matmul 来高效计算两个batch of vectors之间的点积。

@HongTao-Yu
Copy link
Author

感谢您的回答

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants