doc2vec 利用gensim 生成文档向量

利用gensim 直接生成文档向量

    def gen_d2v_corpus(self, lines):

        with open("./data/ques2_result.txt", "wb") as fw:
for line in lines:
fw.write(" ".join(jieba.lcut(line)) + "\n") sents = doc2vec.TaggedLineDocument("./data/ques2_result.txt")
model = doc2vec.Doc2Vec(sents, size = 50, window = 5, alpha = 0.015)
model.train(sents) corpus = model.docvecs
np.save("./output/d2v.corpus.npy", corpus) return np.asarray(corpus)
上一篇:12.Python数值类型(整形、浮点型和复数)及其用法


下一篇:Python变量类型