如何在 word2vec 中的每个训练迭代器后获得一个向量



我想在word2vec中每隔几个迭代得到一个单词向量,例如,我想使用下面的模型。

embedding_model = Word2Vec(test_set, size=300, 
                           window=4, workers=6, 
                           iter=300, sg=1, min_count=10)

在这个模型中,我想每 50 次迭代学习 300 维向量,因为我想在 html d3 中显示连续学习内容。

我该怎么做?

您可以迭代调用train()方法6次,每次epochs=50

model = gensim.models.word2vec.Word2Vec(size=300, window=4, workers=6, sg=1, 
                                        min_count=10)
model.build_vocab(sentences)
for i in range(6):
  model.train(sentences, total_examples=model.corpus_count, epochs=50)
  print(model.wv.word_vec('the'))  # get the intermediate vector(s)

最新更新