Word2Vec

2020-02-12  本文已影响0人  在努力的Jie
1. 区分两种写法
  1. Will always work as long as the namespace is not altered
from gensim.models.word2vec import Word2Vec
  1. Will work as long as models.init keep it available
from gensim.models import Word2Vec
2. nlp中的词向量对比:

word2vec/glove/fastText/elmo/GPT/bert

3. 笔记
wordevec

图上这句话让我理解词嵌入很有帮助:
这个嵌入矩阵包含训练集中每个词的一个向量。
word2vec模型根据数据集中的每个句子进行训练,并且以一个固定窗口在句子上进行滑动,根据句子的上下文来预测固定窗口中间那个词的向量,然后根据一个损失函数和优化方法,来对这个模型进行训练。

4. word2vec训练中文词向量
5. 独热编码 将单词映射到数字向量https://blog.csdn.net/qq_23944915/article/details/99884177
5. word2vec参数详解:

在gensim中,word2vec相关的API都在gensim.models.word2vec中,与算法相关的参数在 gensim.models.word2vec.Word2Vec中。其具体参数说明如下:


现在,训练一个gensim.models.word2vec.Word2Vec模型

import word2vec
from gensim.models.word2vec import LineSentence
sentences = LineSentence('nodup_data222.csv')
model = word2vec.word2vec(sentences,size=100,window=5,min_count = 5,output='new_vecoter')
上一篇 下一篇

猜你喜欢

热点阅读