在加载doc2vec模型期间获得了EOFError

时间:2017-03-01 18:34:51

标签: python-2.7 pickle gensim doc2vec

我无法在我的计算机上加载doc2vec模型,我收到以下错误。但是,当我在其他计算机上加载该模型时,我可以使用该模型。因此,我知道模型是正确构建的。

我应该怎么做。

这是代码:

# coding: utf-8
from gensim.models.doc2vec import Doc2Vec
import gensim.models.doc2vec
from gensim.models.doc2vec import LabeledSentence
import os
import pickle
pth='/home/fatemeh/Step2/input-output/model/iterator'
model= Doc2Vec.load(pth+'/my_model.doc2vec')

这是错误:

    Traceback (most recent call last):
  File "CreateAnnoyIndex.py", line 16, in <module>
    model= Doc2Vec.load(pth+'/my_model.doc2vec')
  File "/usr/local/lib/python2.7/dist-packages/gensim-0.13.3-py2.7-linux-x86_64.egg/gensim/models/word2vec.py", line 1762, in load
    model = super(Word2Vec, cls).load(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gensim-0.13.3-py2.7-linux-x86_64.egg/gensim/utils.py", line 248, in load
    obj = unpickle(fname)
  File "/usr/local/lib/python2.7/dist-packages/gensim-0.13.3-py2.7-linux-x86_64.egg/gensim/utils.py", line 912, in unpickle
    return _pickle.loads(f.read())
EOFError

1 个答案:

答案 0 :(得分:1)

我认为您的模型会导致问题。你用相同型号检查吗?我的意思是以同样的方式构建。请参阅this page