python word2vec
2017-08-16 13:46
204 查看
from gensim.models import Word2Vec from gensim.models.word2vec import LineSentence def gen_embeddings(in_file, out_file, size=100): corpus = LineSentence(in_file) model = Word2Vec( sentences=corpus, size=size, alpha=0.025, window=5, min_count=5, max_vocab_size=None, sample=1e-3, seed=1, workers=3, min_alpha=0.0001, sg=0, hs=0, negative=5, cbow_mean=1, hashfxn=hash, iter=5, null_word=0, trim_rule=None, sorted_vocab=1 ) model.wv.save_word2vec_format(out_file, binary=False)
gen_embeddings('seg.txt','model')
model=Word2Vec().wv.load_word2vec_format('LianCheng', binary=False)
y2 = model.most_similar("供热", topn=10) # 10个最相关的 for item in y2: print (item[0], item[1])
model.wv["供热"]
相关文章推荐
- word2vec的python应用
- gensim实现python对word2vec的训练和计算
- 【word2vec】之 训练模型结果的结构探究 模型改造 python gensim
- gensim实现python对word2vec的训练和计算
- python 下的 word2vec 学习笔记
- python 环境下gensim中的word2vec的使用笔记
- wiki_word2vec_python实验
- python——word2vec
- Python版的Word2Vec -- gensim 学习手札 中文词语相似性度量 V1.1
- word2vec python使用
- Python Tensorflow下的Word2Vec代码解释
- python实现word2vec训练结果bin文件转txt文件
- Python Tensorflow下的Word2Vec代码解释
- python 下的 word2vec 学习笔记
- Python中gensim库word2vec的使用
- 【python gensim使用】word2vec词向量处理英文语料
- Word2Vec的Python版Gensim的使用
- python初步实现word2vec
- gensim中word2vec python源码理解(一)
- 【python gensim使用】word2vec词向量处理英文语料