Skip to content

Commit 907cd68

Browse files
author
tmikolov
committed
bugfix - the vector computation was done before check for out-of-vocabulary words was performed, which resulted in accessing memory outside of the allocated block
1 parent 4896886 commit 907cd68

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compute-accuracy.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ int main(int argc, char **argv)
9797
b3 = b;
9898
for (a = 0; a < N; a++) bestd[a] = 0;
9999
for (a = 0; a < N; a++) bestw[a][0] = 0;
100-
for (a = 0; a < size; a++) vec[a] = (M[a + b2 * size] - M[a + b1 * size]) + M[a + b3 * size];
101100
TQ++;
102101
if (b1 == words) continue;
103102
if (b2 == words) continue;
104103
if (b3 == words) continue;
105104
for (b = 0; b < words; b++) if (!strcmp(&vocab[b * max_w], st4)) break;
106105
if (b == words) continue;
106+
for (a = 0; a < size; a++) vec[a] = (M[a + b2 * size] - M[a + b1 * size]) + M[a + b3 * size];
107107
TQS++;
108108
for (c = 0; c < words; c++) {
109109
if (c == b1) continue;

0 commit comments

Comments
 (0)