word2vec.py 文件源码

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

项目:tensorflow-playground 作者: wangz10 项目源码 文件源码
def sort(self, word):
        '''
        Use an input word to sort words using cosine distance in ascending order
        '''
        assert word in self.dictionary
        i = self.dictionary[word]
        vec = self.final_embeddings[i].reshape(1, -1)
        # Calculate pairwise cosine distance and flatten to 1-d
        pdist = pairwise_distances(self.final_embeddings, vec, metric='cosine').ravel()
        return [self.reverse_dictionary[i] for i in pdist.argsort()]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号