Skip to content

Commit

Permalink
Fix linear decay for learning rate in Doc2Vec.infer_vector. Fix #2061
Browse files Browse the repository at this point in the history
… (#2063)

* Linear decay for learning rate in infer_vector

* remove whitespace
  • Loading branch information
umangv authored and menshikh-iv committed Jun 20, 2018
1 parent e50a057 commit 8715c00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gensim/models/doc2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ def infer_vector(self, doc_words, alpha=0.1, min_alpha=0.0001, steps=5):
if not self.sg:
neu1 = matutils.zeros_aligned(self.trainables.layer1_size, dtype=REAL)

alpha_delta = (alpha - min_alpha) / (steps - 1)

for i in range(steps):
if self.sg:
train_document_dbow(
Expand All @@ -562,7 +564,7 @@ def infer_vector(self, doc_words, alpha=0.1, min_alpha=0.0001, steps=5):
self, doc_words, doctag_indexes, alpha, work, neu1,
learn_words=False, learn_hidden=False, doctag_vectors=doctag_vectors, doctag_locks=doctag_locks
)
alpha = ((alpha - min_alpha) / (steps - i)) + min_alpha
alpha -= alpha_delta

return doctag_vectors[0]

Expand Down

0 comments on commit 8715c00

Please sign in to comment.