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

Fixed bug in loss computation for Word2Vec with hierarchical softmax #3397

Merged
merged 2 commits into from
Nov 3, 2022
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: 2 additions & 2 deletions gensim/models/word2vec_inner.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ cdef void w2v_fast_sentence_sg_hs(

if _compute_loss == 1:
sgn = (-1)**word_code[b] # ch function: 0-> 1, 1 -> -1
lprob = -1*sgn*f_dot
lprob = sgn*f_dot
if lprob <= -MAX_EXP or lprob >= MAX_EXP:
continue
lprob = LOG_TABLE[<int>((lprob + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
Expand Down Expand Up @@ -326,7 +326,7 @@ cdef void w2v_fast_sentence_cbow_hs(

if _compute_loss == 1:
sgn = (-1)**word_code[b] # ch function: 0-> 1, 1 -> -1
lprob = -1*sgn*f_dot
lprob = sgn*f_dot
if lprob <= -MAX_EXP or lprob >= MAX_EXP:
continue
lprob = LOG_TABLE[<int>((lprob + MAX_EXP) * (EXP_TABLE_SIZE / MAX_EXP / 2))]
Expand Down