-
-
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
Added comments explaining logic for changes in PR #1327 #1365
Merged
menshikh-iv
merged 1 commit into
piskvorky:develop
from
chinmayapancholi13:random_state_pr_comments1
May 26, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1117,15 +1117,24 @@ def load(cls, fname, *args, **kwargs): | |
""" | ||
kwargs['mmap'] = kwargs.get('mmap', None) | ||
result = super(LdaModel, cls).load(fname, *args, **kwargs) | ||
|
||
# check if `random_state` attribute has been set after main pickel load | ||
# if set -> the model to be loaded was saved using a >= 0.13.2 version of Gensim | ||
# if not set -> the model to be loaded was saved using a < 0.13.2 version of Gensim, so set `random_state` as the default value | ||
if not hasattr(result, 'random_state'): | ||
result.random_state = utils.get_random_state(None) | ||
result.random_state = utils.get_random_state(None) # using default value `get_random_state(None)` | ||
logging.warning("random_state not set so using default value") | ||
|
||
state_fname = utils.smart_extension(fname, '.state') | ||
try: | ||
result.state = super(LdaModel, cls).load(state_fname, *args, **kwargs) | ||
except Exception as e: | ||
logging.warning("failed to load state from %s: %s", state_fname, e) | ||
|
||
id2word_fname = utils.smart_extension(fname, '.id2word') | ||
# check if `id2word_fname` file is present on disk | ||
# if present -> the model to be loaded was saved using a >= 0.13.2 version of Gensim, so set `result.id2word` using the `id2word_fname` file | ||
# if not present -> the model to be loaded was saved using a < 0.13.2 version of Gensim, so `result.id2word` already set after the main pickel load | ||
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.
|
||
if (os.path.isfile(id2word_fname)): | ||
try: | ||
result.id2word = utils.unpickle(id2word_fname) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
pickel
=>pickle