BLSTM_Bilinear_classification_model.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:models 作者: Jonbean 项目源码 文件源码
def batch_cosine(self, doc_batch_proj, query_batch_proj):
        dot_prod = T.batched_dot(doc_batch_proj, query_batch_proj)

        doc_square = doc_batch_proj ** 2
        query_square = query_batch_proj ** 2

        doc_norm = (T.sqrt(doc_square.sum(axis = 1))).sum()
        query_norm = T.sqrt(query_square.sum(axis = 1)).sum()

        batch_cosine_vec = dot_prod/(doc_norm * query_norm)
        return batch_cosine_vec
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号