NLP到Word2Vec实战班中chinese-sentiment-analysis程序总是运行错误


有人成功运行出这个程序了吗?我运行了,总是报错,改也不行。。。求助
FileNotFoundError Traceback (most recent call last)
<ipython-input-43-f711ef0524c6> in <module>()
2 string='电池充完了电连手机都打不开.简直烂的要命.真是金玉其外,败絮其中!连5号电池都不如'
3 #string='牛逼的手机,从3米高的地方摔下去都没坏,质量非常好'
----> 4 svm_predict(string)

<ipython-input-42-db2cf5612bb0> in svm_predict(string)
1 def svm_predict(string):
2 words=jieba.lcut(string)
----> 3 words_vecs=get_predict_vecs(words)
4 clf=joblib.load('D:/svm_data/svm_model/model.pkl')
5

<ipython-input-41-6f4c04da4530> in get_predict_vecs(words)
1 def get_predict_vecs(words):
2 n_dim = 300
----> 3 imdb_w2v = Word2Vec.load('D:/svm_data/w2v_model/w2v_model.pkl')
4 #imdb_w2v.train(words)
5 train_vecs = build_sentence_vector(words, n_dim,imdb_w2v)

d:\Anaconda3\lib\site-packages\gensim\models\word2vec.py in load(cls, *args, **kwargs)
973 """
974 try:
--> 975 return super(Word2Vec, cls).load(*args, **kwargs)
976 except AttributeError:
977 logger.info('Model saved using code from earlier Gensim Version. Re-loading old model in a compatible way.')

d:\Anaconda3\lib\site-packages\gensim\models\base_any2vec.py in load(cls, *args, **kwargs)
627 @classmethod
628 def load(cls, *args, **kwargs):
--> 629 model = super(BaseWordEmbeddingsModel, cls).load(*args, **kwargs)
630 if model.negative and hasattr(model.wv, 'index2word'):
631 model.vocabulary.make_cum_table(model.wv) # rebuild cum_table from vocabulary

d:\Anaconda3\lib\site-packages\gensim\models\base_any2vec.py in load(cls, fname_or_handle, **kwargs)
276 @classmethod
277 def load(cls, fname_or_handle, **kwargs):
--> 278 return super(BaseAny2VecModel, cls).load(fname_or_handle, **kwargs)
279
280 def save(self, fname_or_handle, **kwargs):

d:\Anaconda3\lib\site-packages\gensim\utils.py in load(cls, fname, mmap)
423 compress, subname = SaveLoad._adapt_by_suffix(fname)
424
--> 425 obj = unpickle(fname)
426 obj._load_specials(fname, mmap, compress, subname)
427 logger.info("loaded %s", fname)

d:\Anaconda3\lib\site-packages\gensim\utils.py in unpickle(fname)
1327
1328 """
-> 1329 with smart_open(fname, 'rb') as f:
1330 # Because of loading from S3 load can't be used (missing readline in smart_open)
1331 if sys.version_info > (3, 0):

d:\Anaconda3\lib\site-packages\smart_open\smart_open_lib.py in smart_open(uri, mode, **kw)
174 encoding = kw.pop('encoding', None)
175 errors = kw.pop('errors', DEFAULT_ERRORS)
--> 176 return file_smart_open(parsed_uri.uri_path, mode, encoding=encoding, errors=errors)
177 elif parsed_uri.scheme in ("s3", "s3n", 's3u'):
178 return s3_open_uri(parsed_uri, mode, **kw)

d:\Anaconda3\lib\site-packages\smart_open\smart_open_lib.py in file_smart_open(fname, mode, encoding, errors)
669 except KeyError:
670 raw_mode = mode
--> 671 raw_fobj = open(fname, raw_mode)
672 decompressed_fobj = compression_wrapper(raw_fobj, fname, raw_mode)
673 decoded_fobj = encoding_wrapper(decompressed_fobj, mode, encoding=encoding, errors=errors)

FileNotFoundError: [Errno 2] No such file or directory: 'D:/svm_data/w2v_model/w2v_model.pkl'
已邀请:

要回复问题请先登录注册

返回顶部