Skip to content

Commit 99e546e

Browse files
author
tmikolov
committed
bugfix in InitUnigramTable() - some words could not have been sampled as negative examples
git-svn-id: http://word2vec.googlecode.com/svn/trunk@42 c84ef02e-58a5-4c83-e53e-41fc32d635eb
1 parent c8d571d commit 99e546e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

word2vec.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ int *table;
5151

5252
void InitUnigramTable() {
5353
int a, i;
54-
long long train_words_pow = 0;
55-
real d1, power = 0.75;
54+
double train_words_pow = 0;
55+
double d1, power = 0.75;
5656
table = (int *)malloc(table_size * sizeof(int));
5757
for (a = 0; a < vocab_size; a++) train_words_pow += pow(vocab[a].cn, power);
5858
i = 0;
59-
d1 = pow(vocab[i].cn, power) / (real)train_words_pow;
59+
d1 = pow(vocab[i].cn, power) / train_words_pow;
6060
for (a = 0; a < table_size; a++) {
6161
table[a] = i;
62-
if (a / (real)table_size > d1) {
62+
if (a / (double)table_size > d1) {
6363
i++;
64-
d1 += pow(vocab[i].cn, power) / (real)train_words_pow;
64+
d1 += pow(vocab[i].cn, power) / train_words_pow;
6565
}
6666
if (i >= vocab_size) i = vocab_size - 1;
6767
}

0 commit comments

Comments
 (0)