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

Replace numpy.random.RandomState with SFC64 - for speed #2864

Merged
merged 1 commit into from
Jun 29, 2020
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.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,8 +1691,8 @@ def prepare_weights(self, hs, negative, wv, update=False, vocabulary=None):
def seeded_vector(self, seed_string, vector_size):
"""Get a random vector (but deterministic by seed_string)."""
# Note: built-in hash() may vary by Python version or even (in Py3.x) per launch
once = random.RandomState(self.hashfxn(seed_string) & 0xffffffff)
return (once.rand(vector_size) - 0.5) / vector_size
once = random.Generator(random.SFC64(self.hashfxn(seed_string) & 0xffffffff))
return (once.random(vector_size) - 0.5) / vector_size

def reset_weights(self, hs, negative, wv):
"""Reset all projection weights to an initial (untrained) state, but keep the existing vocabulary."""
Expand Down