当前位置:网站首页>衡量两个向量相似度的方法:余弦相似度、pytorch 求余弦相似度:torch.nn.CosineSimilarity(dim=1, eps=1e-08)
衡量两个向量相似度的方法:余弦相似度、pytorch 求余弦相似度:torch.nn.CosineSimilarity(dim=1, eps=1e-08)
2022-07-01 03:15:00 【是七叔呀】
余 弦 相 似 度 \color{red}{余弦相似度} 余弦相似度
在NLP的任务里,会对生成两个词向量进行相似度的计算,常常采用余弦相似度公式计算。
余弦相似度用向量空间中两个向量夹角的余弦值作为衡量两个个体间差异的大小。余弦值越接近1,就表明夹角越接近0度,也就是两个向量越相似,这就叫"余弦相似性"。
我们知道,对于两个向量,如果他们之间的夹角越小,那么我们认为这两个向量是越相似的。余弦相似性就是利用了这个理论思想。它通过计算两个向量的夹角的余弦值来衡量向量之间的相似度值。
公式如下:
参考:衡量两个向量相似度的方法:余弦相似度
用于torch的余弦相似度函数:
pytorch 求余弦相似度:torch.nn.CosineSimilarity(dim=1, eps=1e-08)
边栏推荐
- 数组的includes( )
- [nine day training] content III of the problem solution of leetcode question brushing Report
- GCC usage, makefile summary
- EtherCAT原理概述
- Druid monitoring statistics source
- Md5sum operation
- 二叉树神级遍历:Morris遍历
- Keil5中如何做到 0 Error(s), 0 Warning(s).
- C # realize solving the shortest path of unauthorized graph based on breadth first BFS -- complete program display
- 最好用的信任关系自动化脚本(shell)
猜你喜欢

Redis efficient like and cancel function

8 pits of redis distributed lock

倍福TwinCAT3 Ads相关错误详细列表

Keil5中如何做到 0 Error(s), 0 Warning(s).

E15 solution for cx5120 controlling Huichuan is620n servo error

Redis tutorial

Basic concepts of database

Edge drawing: a combined real-time edge and segment detector

数据交换 JSON

Druid monitoring statistics source
随机推荐
C语言多线程编程入门学习笔记
Introduction to webrtc concept -- an article on understanding source, track, sink and mediastream
C#实现基于广度优先BFS求解无权图最短路径----完整程序展示
leetcode 1482 猜猜看啊,这道题目怎么二分?
后台系统右边内容如何出现滚动条和解决双滚动条的问题
Feign remote call and getaway gateway
Ridge regression and lasso regression
md5sum操作
Split(), split(), slice(), can't you tell?
Learning notes for introduction to C language multithreaded programming
Redis efficient like and cancel function
Redis高效点赞与取消功能
The shell script uses two bars to receive external parameters
Hello World generation
Elk elegant management server log
Kmeans
GCC usage, makefile summary
Take you through a circuit board, from design to production (dry goods)
数组的includes( )
Let's just say I can use thousands of expression packs