You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you calculate the _expTable, in file Word2Vec.cs line 88 you use a bad issued integer division, and this yields always 0 if the numerator is less than numerator, which is always true, revise the calculated Exptable, all elements are the same. The solution is simple and is casting the ExpTableSize to double:
(other more elegant is to precompute is and define as a double constant, but this is used only on initialization) Also I would have done this as a static table, so if you use the class in a library more than once, you don't need to recalc the exptable every time (provided sizes are the same)
code from line 86 (aprox.)
for (var i = 0; i < ExpTableSize; i++)
{
_expTable[i] = (float)Math.Exp((i / (double)ExpTableSize * 2 - 1) * MaxExp); // Precompute the exp() table
_expTable[i] = _expTable[i] / (_expTable[i] + 1); // Precompute f(x) = x / (x + 1)
}
NOTE: this kind of errors (integer divisions rendered as integer, and thought as floating point) are rather common on porting from C++, be careful, I am still searching the code for them!
The text was updated successfully, but these errors were encountered:
When you calculate the _expTable, in file Word2Vec.cs line 88 you use a bad issued integer division, and this yields always 0 if the numerator is less than numerator, which is always true, revise the calculated Exptable, all elements are the same. The solution is simple and is casting the ExpTableSize to double:
(other more elegant is to precompute is and define as a double constant, but this is used only on initialization) Also I would have done this as a static table, so if you use the class in a library more than once, you don't need to recalc the exptable every time (provided sizes are the same)
code from line 86 (aprox.)
NOTE: this kind of errors (integer divisions rendered as integer, and thought as floating point) are rather common on porting from C++, be careful, I am still searching the code for them!
The text was updated successfully, but these errors were encountered: