Skip to content

Commit

Permalink
Replace numpy.random.RandomState with SFC64 - for speed
Browse files Browse the repository at this point in the history
  • Loading branch information
zygm0nt committed Jun 22, 2020
1 parent 374de28 commit 3f41fd7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gensim/models/word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ 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)
once = random.SFC64(self.hashfxn(seed_string) & 0xffffffff)
return (once.rand(vector_size) - 0.5) / vector_size

def reset_weights(self, hs, negative, wv):
Expand Down

0 comments on commit 3f41fd7

Please sign in to comment.