-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[WIP] HDP #1055
[WIP] HDP #1055
Changes from all commits
7bc3ddb
4d3af60
ae9de89
e639fda
e03f67f
565b39e
57762c9
76a982c
e101b30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
import subprocess | ||
|
||
import numpy | ||
import numbers | ||
import scipy.sparse | ||
|
||
if sys.version_info[0] >= 3: | ||
|
@@ -80,6 +81,21 @@ def smart_open(fname, mode='rb'): | |
RE_HTML_ENTITY = re.compile(r'&(#?)([xX]?)(\w{1,8});', re.UNICODE) | ||
|
||
|
||
def get_random_state(seed): | ||
""" Turn seed into a np.random.RandomState instance. | ||
|
||
Method originally from maciejkula/glove-python, and written by @joshloyal | ||
""" | ||
if seed is None or seed is numpy.random: | ||
return numpy.random.mtrand._rand | ||
if isinstance(seed, (numbers.Integral, numpy.integer)): | ||
return numpy.random.RandomState(seed) | ||
if isinstance(seed, numpy.random.RandomState): | ||
return seed | ||
raise ValueError('%r cannot be used to seed a numpy.random.RandomState' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No vertical indent in gensim, please use hanging indent. @tmylk this keeps happening over and over -- watch out for this in reviews. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad, I had just copy-pasted this from the existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bhargavvader Thanks! |
||
' instance' % seed) | ||
|
||
|
||
def synchronous(tlockname): | ||
""" | ||
A decorator to place an instance-based lock around a method. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is it different from
hdp_to_lda
? Add a commentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed duplicate code, added comment.