KiWiChoco
KiWiChoco

Reputation: 53

How can I get a vector after each training iter in word2vec?

I want to get a vector of words every few iter in word2vec, e.g., I would like to use the model below.

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

In this model, I want to get the 300-dimensional vectors learned for every 50 iterations, because I want to show continuous learning contents in html d3.

How can I do this?

Upvotes: 2

Views: 285

Answers (1)

Maxim
Maxim

Reputation: 53768

You can call train() method iteratively 6 times, each with 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)

Upvotes: 2

Related Questions