# https://stackoverflow.com/questions/18424228/cosine-similarity-between-2-number-lists # a = [3, 45, 7, 2] # b = [2, 54, 13, 15] # a = torch.Tensor([1, 2, 3]) # F.cosine_similarity(a,b, dim=0) # torch.cosine_similarity(a, b,dim=0) # print 1 - spatial.distance.cosine(a, b) # print cosine_similarity([a], [b])[0][0] # # print 1 - spatial.distance.cosine(a, b) # print dot(a, b)/(norm(a)*norm(b)) # print np.inner(a, b)/(norm(a)*norm(b))
06-22
7280
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-28
5467
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)