def cosine(q,a):
pooled_len_1 = tf.sqrt(tf.reduce_sum(q * q, 1))
pooled_len_2 = tf.sqrt(tf.reduce_sum(a * a, 1))
pooled_mul_12 = tf.reduce_sum(q * a, 1)
score = tf.div(pooled_mul_12, pooled_len_1 * pooled_len_2 +1e-8, name="scores")
return score
tensorflow 余弦相似度实现
TensorFlow相关文章
最近热门
- Gamma函数及其函数变形
- 多模态对齐(Multimodal Alignment)
- GRPO(Group Relative Policy Optimization)
- MRR(Mean Reciprocal Rank):一个信息检索和推荐系统中常用的评价指标
- 多视图学习 (Multi-View Learning)
- Apache Arrow
- HDR:高动态范围成像技术(High Dynamic Range Imaging)
- 连续归一化流(Continuous Normalizing Flows,简称CNF)
- 近线召回
- HMCN(Hierarchical Multi-scale Convolutional Neural network)模型
最常浏览
- 016 推荐系统 | 排序学习(LTR - Learning To Rank)
- 偏微分符号
- i.i.d(又称IID)
- 利普希茨连续条件(Lipschitz continuity)
- (error) MOVED 原因和解决方案
- TextCNN详解
- 找不到com.google.protobuf.GeneratedMessageV3的类文件
- Deployment failed: repository element was not specified in the POM inside distributionManagement
- cannot access com.google.protobuf.GeneratedMessageV3 解决方案
- CLUSTERDOWN Hash slot not served 问题原因和解决办法
×