{"action":"created","issue":{"url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1936","repository_url":"https://api.github.com/repos/RaRe-Technologies/gensim","labels_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1936/labels{/name}","comments_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1936/comments","events_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1936/events","html_url":"https://github.com/RaRe-Technologies/gensim/issues/1936","id":300128433,"number":1936,"title":"Gensim's load fails to load a saved model ","user":{"login":"dotslash","id":959827,"avatar_url":"https://avatars1.githubusercontent.com/u/959827?v=4","gravatar_id":"","url":"https://api.github.com/users/dotslash","html_url":"https://github.com/dotslash","followers_url":"https://api.github.com/users/dotslash/followers","following_url":"https://api.github.com/users/dotslash/following{/other_user}","gists_url":"https://api.github.com/users/dotslash/gists{/gist_id}","starred_url":"https://api.github.com/users/dotslash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotslash/subscriptions","organizations_url":"https://api.github.com/users/dotslash/orgs","repos_url":"https://api.github.com/users/dotslash/repos","events_url":"https://api.github.com/users/dotslash/events{/privacy}","received_events_url":"https://api.github.com/users/dotslash/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-02-26T06:59:29Z","updated_at":"2018-04-10T03:00:48Z","closed_at":"2018-04-09T05:44:55Z","author_association":"NONE","body":"#### Description\r\nI was trying to load fasttext embedding into Word2Vec. The load time is very slow. (10 mins). So I was trying out if saving and loading the model will be faster. However the load step is failing.\r\n\r\n\r\n#### Steps/Code/Corpus to Reproduce\r\nmodel_file = '/path/to/original'\r\nsaved_model = '/path/to/save'\r\nmodel = gensim.models.KeyedVectors.load_word2vec_format(model_file)\r\nmodel.save(saved_model)\r\nmodel = Word2Vec.load(saved_model)\r\n\r\n\r\n#### Actual Results\r\nThe load step fails with the following error.\r\n\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\n~/.envs/dspy3/lib/python3.5/site-packages/gensim/models/word2vec.py in load(cls, *args, **kwargs)\r\n    974         try:\r\n--> 975             return super(Word2Vec, cls).load(*args, **kwargs)\r\n    976         except AttributeError:\r\n\r\n~/.envs/dspy3/lib/python3.5/site-packages/gensim/models/base_any2vec.py in load(cls, *args, **kwargs)\r\n    629         model = super(BaseWordEmbeddingsModel, cls).load(*args, **kwargs)\r\n--> 630         if model.negative and hasattr(model.wv, 'index2word'):\r\n    631             model.vocabulary.make_cum_table(model.wv)  # rebuild cum_table from vocabulary\r\n\r\nAttributeError: 'Word2VecKeyedVectors' object has no attribute 'negative'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nAttributeError                            Traceback (most recent call last)\r\n<ipython-input-18-7af8ac3135e5> in <module>()\r\n----> 1 model = LogExecTime(\"LoadSaved\", LoadSaved)\r\n\r\n<ipython-input-17-2402a78ca1d2> in LogExecTime(name, f, *args)\r\n      7   start = time.time()\r\n      8   print(\"Starting {}\".format(name))\r\n----> 9   ret = f(*args)\r\n     10   print(\"{} took {} secs\".format(name, time.time()-start))\r\n     11   return ret\r\n\r\n<ipython-input-17-2402a78ca1d2> in LoadSaved()\r\n     23 def LoadSaved():\r\n     24     saved_model = os.path.expanduser(\"~/code/fb.fasttext/crawl-300d-2M.vec.gensim\")\r\n---> 25     return Word2Vec.load(saved_model)\r\n     26 \r\n     27 \r\n\r\n~/.envs/dspy3/lib/python3.5/site-packages/gensim/models/word2vec.py in load(cls, *args, **kwargs)\r\n    977             logger.info('Model saved using code from earlier Gensim Version. Re-loading old model in a compatible way.')\r\n    978             from gensim.models.deprecated.word2vec import load_old_word2vec\r\n--> 979             return load_old_word2vec(*args, **kwargs)\r\n    980 \r\n    981 \r\n\r\n~/.envs/dspy3/lib/python3.5/site-packages/gensim/models/deprecated/word2vec.py in load_old_word2vec(*args, **kwargs)\r\n    151 \r\n    152 def load_old_word2vec(*args, **kwargs):\r\n--> 153     old_model = Word2Vec.load(*args, **kwargs)\r\n    154     params = {\r\n    155         'size': old_model.vector_size,\r\n\r\n~/.envs/dspy3/lib/python3.5/site-packages/gensim/models/deprecated/word2vec.py in load(cls, *args, **kwargs)\r\n   1614     @classmethod\r\n   1615     def load(cls, *args, **kwargs):\r\n-> 1616         model = super(Word2Vec, cls).load(*args, **kwargs)\r\n   1617         # update older models\r\n   1618         if hasattr(model, 'table'):\r\n\r\n~/.envs/dspy3/lib/python3.5/site-packages/gensim/models/deprecated/old_saveload.py in load(cls, fname, mmap)\r\n     85         compress, subname = SaveLoad._adapt_by_suffix(fname)\r\n     86 \r\n---> 87         obj = unpickle(fname)\r\n     88         obj._load_specials(fname, mmap, compress, subname)\r\n     89         logger.info(\"loaded %s\", fname)\r\n\r\n~/.envs/dspy3/lib/python3.5/site-packages/gensim/models/deprecated/old_saveload.py in unpickle(fname)\r\n    378             b'gensim.models.wrappers.fasttext', b'gensim.models.deprecated.fasttext_wrapper')\r\n    379         if sys.version_info > (3, 0):\r\n--> 380             return _pickle.loads(file_bytes, encoding='latin1')\r\n    381         else:\r\n    382             return _pickle.loads(file_bytes)\r\n\r\nAttributeError: Can't get attribute 'Word2VecKeyedVectors' on <module 'gensim.models.deprecated.keyedvectors' from '/Users/stps/.envs/dspy3/lib/python3.5/site-packages/gensim/models/deprecated/keyedvectors.py'>\r\n\r\n\r\nPlease paste or specifically describe the actual output or traceback. -->\r\n\r\n#### Versions\r\nDarwin-17.4.0-x86_64-i386-64bit\r\nPython 3.5.2 (default, Jun 29 2016, 13:43:58)\r\n[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]\r\nNumPy 1.14.1\r\nSciPy 1.0.0\r\ngensim 3.3.0\r\nFAST_VERSION 0\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/comments/379958531","html_url":"https://github.com/RaRe-Technologies/gensim/issues/1936#issuecomment-379958531","issue_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1936","id":379958531,"user":{"login":"menshikh-iv","id":15094669,"avatar_url":"https://avatars2.githubusercontent.com/u/15094669?v=4","gravatar_id":"","url":"https://api.github.com/users/menshikh-iv","html_url":"https://github.com/menshikh-iv","followers_url":"https://api.github.com/users/menshikh-iv/followers","following_url":"https://api.github.com/users/menshikh-iv/following{/other_user}","gists_url":"https://api.github.com/users/menshikh-iv/gists{/gist_id}","starred_url":"https://api.github.com/users/menshikh-iv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/menshikh-iv/subscriptions","organizations_url":"https://api.github.com/users/menshikh-iv/orgs","repos_url":"https://api.github.com/users/menshikh-iv/repos","events_url":"https://api.github.com/users/menshikh-iv/events{/privacy}","received_events_url":"https://api.github.com/users/menshikh-iv/received_events","type":"User","site_admin":false},"created_at":"2018-04-10T03:00:48Z","updated_at":"2018-04-10T03:00:48Z","author_association":"MEMBER","body":"@piskvorky maybe write explicitly in error message that \"`kv` isn't `w2v` (this is only one matrix with some metadata, for loading full `w2v` model please use `w2v.save` -> `w2v.load`)\""}}
{"actor":{"display_login":"menshikh-iv"}}