-
-
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
Reduce Phraser
memory usage (drop frequencies)
#2208
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
242c80e
fix phraser memory
jenishah bba2e46
reduce phraser memory
jenishah 9f9b05f
using isinstance
jenishah c391fe5
update model when loaded
jenishah d154e3a
update model when loaded
jenishah 40b6672
update model when loaded
jenishah 40dcbde
updated changes
jenishah 21c3911
updated changes
jenishah 80e9222
update changes
jenishah 9943909
Merge remote-tracking branch 'upstream/develop' into jshah_ph_mem
menshikh-iv 021226a
fix loading
menshikh-iv 9de2495
make test better
menshikh-iv 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
Binary file not shown.
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
import unittest | ||
|
||
import six | ||
|
||
import numpy as np | ||
|
||
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. Keep the blank please. We separate third party modules from internal modules by a blank line (another visual block). The blank line between |
||
from gensim.utils import to_unicode | ||
|
@@ -646,6 +645,16 @@ def testEncoding(self): | |
self.assertTrue(isinstance(transformed, six.text_type)) | ||
|
||
|
||
class TestPhraserModelCompatibilty(unittest.TestCase): | ||
|
||
def testCompatibilty(self): | ||
bigram_loaded = Phraser.load(datapath("phraser_model_3dot6")) | ||
test_sentences = [u'trees', u'graph', u'minors'] | ||
prev_ver = bigram_loaded[test_sentences] | ||
expected_res = ['trees_graph', 'minors'] | ||
self.assertEqual(prev_ver, expected_res) | ||
|
||
|
||
if __name__ == '__main__': | ||
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.DEBUG) | ||
unittest.main() |
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.
We don't want to be checking the object version at run-time.
We want to check during
load
and convert to new object format if necessary right during loading.Please have a look at LdaModel.load for an example of "conditional" loading for backward compatibility.
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.
Is there any better approach other than to look at the type of values() in
phrasegrams
dict of the object?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.
No, I think that's fine: look at the type when loading the object, and if it's the "old" type (tuple), convert to the new type (floats) right away. Then at runtime, we continue working with the new type only.