У меня есть вопрос во время следования простому учебнику по gensim на веб-сайте gensim ,
>>> from gensim.test.utils import common_texts, get_tmpfile
>>> from gensim.models import Word2Vec
>>>
>>> path = get_tmpfile("word2vec.model")
>>>
>>> model = Word2Vec(common_texts, size=100, window=5, min_count=1, workers=4)
>>> model.save("word2vec.model")
>>> model = Word2Vec.load("word2vec.model")
>>> model.train([["hello", "world"]], total_examples=1, epochs=1)
>>> from gensim.models import KeyedVectors
>>>
>>> path = get_tmpfile("wordvectors.kv")
>>>
А когда я попробовал ниже,
>>> model.wv.save(path)
>>> wv = KeyedVectors.load("model.wv", mmap='r')
IВозникла следующая ошибка:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-81-eee6865b677b> in <module>
1 path = get_tmpfile('wordvectors.kv')
2 model.wv.save(path)
----> 3 KeyedVectors.load("model.wv",mmap='r')
/anaconda3/lib/python3.7/site-packages/gensim/models/keyedvectors.py in load(cls, fname_or_handle, **kwargs)
210 @classmethod
211 def load(cls, fname_or_handle, **kwargs):
--> 212 return super(BaseKeyedVectors, cls).load(fname_or_handle, **kwargs)
213
214 def similarity(self, entity1, entity2):
/anaconda3/lib/python3.7/site-packages/gensim/utils.py in load(cls, fname, mmap)
420 compress, subname = SaveLoad._adapt_by_suffix(fname)
421
--> 422 obj = unpickle(fname)
423 obj._load_specials(fname, mmap, compress, subname)
424 logger.info("loaded %s", fname)
/anaconda3/lib/python3.7/site-packages/gensim/utils.py in unpickle(fname)
1356
1357 """
-> 1358 with smart_open(fname, 'rb') as f:
1359 # Because of loading from S3 load can't be used (missing readline in smart_open)
1360 if sys.version_info > (3, 0):
/anaconda3/lib/python3.7/site-packages/smart_open/smart_open_lib.py in smart_open(uri, mode, **kw)
179 raise TypeError('mode should be a string')
180
--> 181 fobj = _shortcut_open(uri, mode, **kw)
182 if fobj is not None:
183 return fobj
/anaconda3/lib/python3.7/site-packages/smart_open/smart_open_lib.py in _shortcut_open(uri, mode, **kw)
299 #
300 if six.PY3:
--> 301 return open(parsed_uri.uri_path, mode, buffering=buffering, **open_kwargs)
302 elif not open_kwargs:
303 return open(parsed_uri.uri_path, mode, buffering=buffering)
FileNotFoundError: [Errno 2] No such file or directory: 'model.wv'
Кто-нибудь знает причину этого сообщения? Как я могу узнать, что у меня есть файл 'model.wv'?
Заранее спасибо!