diff --git a/gensim/models/word2vec.py b/gensim/models/word2vec.py index b172f57c8a..d4a4ba992e 100755 --- a/gensim/models/word2vec.py +++ b/gensim/models/word2vec.py @@ -1986,9 +1986,6 @@ def _load_specials(self, *args, **kwargs): for a in ('hashfxn', 'layer1_size', 'seed', 'syn1neg', 'syn1'): if hasattr(self.trainables, a): setattr(self, a, getattr(self.trainables, a)) - if hasattr(self, 'syn1'): - self.syn1 = self.syn1 - del self.syn1 del self.trainables if not hasattr(self, 'shrink_windows'): self.shrink_windows = True diff --git a/gensim/test/test_data/model-from-gensim-3.8.0.w2v b/gensim/test/test_data/model-from-gensim-3.8.0.w2v new file mode 100644 index 0000000000..40f7e22e32 Binary files /dev/null and b/gensim/test/test_data/model-from-gensim-3.8.0.w2v differ diff --git a/gensim/test/test_word2vec.py b/gensim/test/test_word2vec.py index d1749e4bfa..a07cf08b10 100644 --- a/gensim/test/test_word2vec.py +++ b/gensim/test/test_word2vec.py @@ -275,6 +275,13 @@ def test_persistence(self): self.assertTrue(np.allclose(wv.vectors, loaded_wv.vectors)) self.assertEqual(len(wv), len(loaded_wv)) + def test_persistence_backwards_compatible(self): + """Can we still load a model created with an older gensim version?""" + path = datapath('model-from-gensim-3.8.0.w2v') + model = word2vec.Word2Vec.load(path) + x = model.score(['test']) + assert x is not None + def test_persistence_from_file(self): """Test storing/loading the entire model trained with corpus_file argument.""" with temporary_file(get_tmpfile('gensim_word2vec.tst')) as corpus_file: