Gensim库之Doc2Vec模型详解

models.doc2vec – Doc2vec paragraph embeddings: TaggedDocument: 对于输入的文档 text,转换为:TaggedDocument(text, [i])的形式,i为文档编号 class gensim.models.doc2vec.Doc2Vec( documents=None, 输入语料库,是TaggedDocument列表 corpus_file=None, Path to a corpus file in LineSentence format. dm_mean=None, 取0,则使用上下文词向量的和。取1,使用平均值。 仅当dm在非串联模式下使用时适用(dm_concat=0)。 dm=1, 选择训练算法,dm = 1 使用PV-DM;dm = 0,使用PV-DBOW dbow_words=0, 取1,则与dbow-doc向量训练同时训练单词向量(以Skip-gram的方式); 取0,则仅训练文档向量(更快)。 dm_concat=0, 取1时,则使用上下文向量的串联,取0时求和/平均值; negative = 0, >0,使用负抽样(噪声词在5~20之间);=0,不适用噪声词; epochs (int, optional),迭代次数; hs ({1,0}, optional), 取 1, 使用hierarchical softmax . 取 0, 且negative 非0, 使用负抽样 . dm_tag_count=1, docvecs=None, docvecs_mapfile=None, comment=None, trim_rule=None, callbacks=(), **kwargs)

使用Doc2Vec()方法训练得到的model中包含以下对象:
(1)wv(Word2VecKeyedVectors):
word2vec对象存储单词和向量之间的映射。用于对向量进行查找、距离、相似性计算等操作。
方法:
① closer_than(entity1, entity2)
Get all entities that are closer to entity1 than entity2 is to entity1.
② cosine_similarities(vector_1, vectors_all)
Compute cosine similarities between one vector and a set of other vectors.
③ distance(w1, w2)
Compute cosine distance between two words.
④ distances(word_or_vector, other_words=())
Compute cosine distances from given word or vector to all words in other_words.
If other_words is empty, return distance between word_or_vectors and all words
in vocab.
⑤ get_vector(word)
Get the entity’s representations in vector space, as a 1D numpy array.
⑥ most_similar_cosmul(positive=None, negative=None, topn=10)
Find the top-N most similar words, using the multiplicative combination objective.
⑦ most_similar_to_given(entity1, entities_list)
Get the entity from entities_list most similar to entity1.
⑧ n_similarity(ws1, ws2)
Compute cosine similarity between two sets of words.
⑨ relative_cosine_similarity(wa, wb, topn=10)
Compute the relative cosine similarity between two words given top-n similar words;
⑩ save(path) Save KeyedVectors. load(path)Load KeyedVectors.
⑪ wmdistance(document1, document2)
Compute the Word Mover’s Distance(词移距离) between two documents.
⑫ word_vec(word, use_norm=False)
Get word representations in vector space, as a 1D numpy array.
(2)docvecs(Doc2VecKeyedVectors):
此对象包含段落向量。记住,这个模型和word2vec之间的唯一区别是,除了词向量之外,我们还包括段落嵌入
来捕获段落。
该对象中的方法基本与WV中的方法相同;
(3)vocabulary(Doc2VecVocab):
这个对象表示模型的词汇表(字典)。除了跟踪所有独特的单词之外,这个对象还提供了额外的功能,比如按频率
对单词排序,或者丢弃非常罕见的单词。

Doc2Vec的方法:
①most_similar(**kwargs) Deprecated, use self.wv.most_similar() instead.
②most_similar_cosmul(**kwargs) Deprecated, use self.wv.most_similar_cosmul() instead.
③n_similarity(**kwargs) Deprecated, use self.wv.n_similarity() instead.

Gensim库之Doc2Vec模型详解相关推荐

  1. 使用pickle保存机器学习模型详解及实战(pickle、joblib)

    使用pickle保存机器学习模型详解及实战 pickle模块实现了用于序列化和反序列化Python对象结构的二进制协议. "Pickling"是将Python对象层次结构转换为字节 ...

  2. TensorFlow Wide And Deep 模型详解与应用 TensorFlow Wide-And-Deep 阅读344 作者简介:汪剑,现在在出门问问负责推荐与个性化。曾在微软雅虎工作,

    TensorFlow Wide And Deep 模型详解与应用 TensorFlow Wide-And-Deep 阅读344  作者简介:汪剑,现在在出门问问负责推荐与个性化.曾在微软雅虎工作,从事 ...

  3. TensorFlow Wide And Deep 模型详解与应用

    Wide and deep 模型是 TensorFlow 在 2016 年 6 月左右发布的一类用于分类和回归的模型,并应用到了 Google Play 的应用推荐中 [1].wide and dee ...

  4. tensorRT 部署 YOLOV5模型详解

    tensorRT 部署 YOLOV5模型详解 第一步: 下载tensorRT库 https://developer.nvidia.com/nvidia-tensorrt-8x-download 欢迎使 ...

  5. OpenAI GPT-3模型详解

    OpenAI GPT-3模型详解 针对文本生成和代码生成这两大类场景,OpenAPI分别提供了GPT-3和Codex模型, 模型 描述 GPT-3 一组能够理解和生成自然语言的模型 Codex 一组可 ...

  6. 憨批的语义分割4——pspnet模型详解以及训练自己的pspnet模型(划分斑马线)

    憨批的语义分割4--pspnet模型详解以及训练自己的pspnet模型(划分斑马线) 注意事项 学习前言 模型部分 什么是pspnet模型 pspnet模型的代码实现 1.主干模型Mobilenet. ...

  7. 机器学习(六)树模型详解

    树模型详解 决策树 决策树模型 ① 树模型不用做scaling ② 树模型不太需要做离散化 ③ 用Xgboost等工具库,是不需要做缺失值填充 ④ 树模型是非线性模型,有非线性的表达能力 决策树基于& ...

  8. Transformer 模型详解

    Transformer 是 Google 的团队在 2017 年提出的一种 NLP 经典模型,现在比较火热的 Bert 也是基于 Transformer.Transformer 模型使用了 Self- ...

  9. 数学建模——智能优化之模拟退火模型详解Python代码

    数学建模--智能优化之模拟退火模型详解Python代码 #本功能实现最小值的求解#from matplotlib import pyplot as plt import numpy as np imp ...

  10. 数学建模——智能优化之粒子群模型详解Python代码

    数学建模--智能优化之粒子群模型详解Python代码 import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplo ...

最新文章

  1. 什么水平能做java中级工程师,挑战大厂重燃激情!
  2. android studio failed to open zip file,Android Studio出现Failed to open zip file问题的解决方法...
  3. .NET6 新功能和新生态
  4. Java中接口定义成员变量
  5. 解决在firefox浏览器不支持ajax的transport.responseXml方法问题
  6. python get 函数-python的__get__、__set__、__delete__(1)
  7. 计算机印屏幕功能无法使用,笔记本电脑无法使用外接显示屏幕扩展功能
  8. 作数学题应不该用计算机,数学奥数考试
  9. 分享几个手机和电脑上的百宝箱工具
  10. 51单片机的定时器TMOD的小记
  11. 建设网站的过程会有哪些问题,如何去注意呢
  12. 朗强:HDMI分配延长器的作用
  13. Mysql表和数据的复制操作
  14. 华为中国生态伙伴大会2019盛大开幕:智能进化 共赢生态未来
  15. 看完了想点赞的文章!| 数据类好文推荐
  16. 机器人史宾_史宾机器人:重启
  17. arduino学习笔记十八--红外遥控检测
  18. 猿学~黑客、红客、白帽子之间的技术较量,为什么大公司都有黑客团队?
  19. 启动Zookeeper报错:Error contacting service. It is probably not running.
  20. 搜索引擎下拉菜单 提示关键词 接口API (百度长尾词 淘宝长尾词)

热门文章

  1. 微信小程序样式padding理解
  2. Python功能实现:为pdf电子书籍生成书签目录
  3. 照片尺寸大小是多少厘米
  4. IDEA 2020 返回上一步快捷键
  5. 西南农业大学成教学院有计算机专业吗,西南农业大学计算机应用与技巧网上功课及答案...
  6. Linux通过域名查ip
  7. 1万美元FS-ISAC网络安全奖学金
  8. E1--千兆以太网接口测试应用2022-09-07
  9. 中国电信物联网平台使用笔记8:获取物联网平台数据1
  10. 小程序中的flex_在Flex应用程序中启用辅助功能