-
-
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
Fixes issues while loading word2vec
and doc2vec
models saved using old Gensim versions. Fix #2000, #1977
#2012
Changes from 2 commits
4edf610
dd1630c
f8b4e32
e09eba7
b572679
310e652
86e2575
b71a8c4
dc54d38
fd5e5b1
89edbe7
463f491
9871304
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 |
---|---|---|
|
@@ -127,6 +127,22 @@ def testLoadOldModel(self): | |
model = doc2vec.Doc2Vec.load(datapath(model_file)) | ||
self.model_sanity(model) | ||
|
||
# Test loading doc2vec models from all previous versions | ||
old_versions = [ | ||
'0.12.0', '0.12.1', '0.12.2', '0.12.3', '0.12.4', | ||
'0.13.0', '0.13.1', '0.13.2', '0.13.3', '0.13.4', | ||
'1.0.0', '1.0.1', '2.0.0', '2.1.0', '2.2.0', '2.3.0', | ||
'3.0.0', '3.1.0', '3.2.0', '3.3.0', '3.4.0' | ||
] | ||
|
||
saved_models_dir = datapath('old_d2v_models') | ||
for old_version in old_versions: | ||
model = doc2vec.Doc2Vec.load(os.path.join(saved_models_dir, 'd2v_{}.mdl'.format(old_version))) | ||
self.assertTrue(len(model.wv.vocab) == 3) | ||
self.assertTrue(model.wv.vectors.shape == (3, 4)) | ||
self.assertTrue(model.docvecs.vectors_docs.shape == (2, 4)) | ||
self.assertTrue(model.docvecs.count == 2) | ||
|
||
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. Can you add here Also, please try to update model (as for w2v) |
||
def test_unicode_in_doctag(self): | ||
"""Test storing document vectors of a model with unicode titles.""" | ||
model = doc2vec.Doc2Vec(DocsLeeCorpus(unicode_tags=True), min_count=1) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -789,6 +789,20 @@ def testLoadOldModel(self): | |
self.assertEqual(model.max_final_vocab, None) | ||
self.assertEqual(model.vocabulary.max_final_vocab, None) | ||
|
||
# Test loading word2vec models from all previous versions | ||
old_versions = [ | ||
'0.12.0', '0.12.1', '0.12.2', '0.12.3', '0.12.4', | ||
'0.13.0', '0.13.1', '0.13.2', '0.13.3', '0.13.4', | ||
'1.0.0', '1.0.1', '2.0.0', '2.1.0', '2.2.0', '2.3.0', | ||
'3.0.0', '3.1.0', '3.2.0', '3.3.0', '3.4.0' | ||
] | ||
|
||
saved_models_dir = datapath('old_w2v_models') | ||
for old_version in old_versions: | ||
model = word2vec.Word2Vec.load(os.path.join(saved_models_dir, 'w2v_{}.mdl'.format(old_version))) | ||
self.assertTrue(len(model.wv.vocab) == 3) | ||
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. add |
||
self.assertTrue(model.wv.vectors.shape == (3, 4)) | ||
|
||
@log_capture() | ||
def testBuildVocabWarning(self, l): | ||
"""Test if warning is raised on non-ideal input to a word2vec model""" | ||
|
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.
better
datapath('old_d2v_models/d2v_{}.mdl')
and format later