python word2vector (一)

from gensim.test.utils import common_texts, get_tmpfile
from gensim.models import Word2Vec

path = get_tmpfile("word2vec.model")

model = Word2Vec(common_texts, size=100, window=5, min_count=1, workers=4)
model.save("word2vec.model")

model = Word2Vec.load("word2vec.model")
'''
model.train([["hello", "world"]], total_examples=1, epochs=1)
'''
#(0, 2)

vector = model.wv['computer']  # numpy vector of a word

print('#'*100)

print(vector
posted @ 2018-07-31 22:58  luoganttcc  阅读(145)  评论(0编辑  收藏  举报