[Bug Fix] fix cosine_similarity error in examples (#648)

cosine_similarity is error

余弦相似度计算错误
np.linalg.norm 二范数 已经开过根号

Co-Authored-By: Chris Kong <chriskong93@163.com>
This commit is contained in:
Chris Kong
2022-11-21 21:25:27 +08:00
committed by GitHub
parent 823b3f7015
commit 8e56b81055
4 changed files with 4 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ def cosine_similarity(a, b):
mul_a = np.linalg.norm(a, ord=2)
mul_b = np.linalg.norm(b, ord=2)
mul_ab = np.dot(a, b)
return mul_ab / (np.sqrt(mul_a) * np.sqrt(mul_b))
return mul_ab / (mul_a * mul_b)
def parse_arguments():