Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linear decay for learning rate in Doc2Vec.infer_vector. Fix #2061 #2063

Merged
merged 2 commits into from
Jun 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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