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

negative_samling #7

Open
Mayar2009 opened this issue Feb 23, 2020 · 1 comment
Open

negative_samling #7

Mayar2009 opened this issue Feb 23, 2020 · 1 comment

Comments

@Mayar2009
Copy link

hi!
pow_frequency = np.array(list(self.word_frequency.values())) ** 0.5

should not be
pow_frequency = np.array(list(self.word_frequency.values())) ** 0.75

@Andras7
Copy link
Owner

Andras7 commented Aug 24, 2020

Hi!
It does not matter too much.
My implementation comes from fasttext:
void Model::initTableNegatives(const std::vector<int64_t>& counts) { real z = 0.0; for (size_t i = 0; i < counts.size(); i++) { z += pow(counts[i], 0.5); } for (size_t i = 0; i < counts.size(); i++) { real c = pow(counts[i], 0.5); for (size_t j = 0; j < c * NEGATIVE_TABLE_SIZE / z; j++) { negatives.push_back(i); } } std::shuffle(negatives.begin(), negatives.end(), rng); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants