1
我想讀我的預訓練doc2vec型號:Gensim:如何加載預訓練的doc2vec模型?
from gensim.models import Doc2Vec
model = Doc2Vec.load('/path/to/pretrained/model')
然而,閱讀的過程中出現了錯誤。任何人都可以建議如何處理這個?這是錯誤:
AttributeErrorTraceback (most recent call last)
<ipython-input-9-819b254ac835> in <module>()
----> 1 model = Doc2Vec.load('/path/to/pretrained/model')
/opt/jupyter-notebook/.local/lib/python2.7/site-packages/gensim/models/word2vec.pyc in load(cls, *args, **kwargs)
1682 @classmethod
1683 def load(cls, *args, **kwargs):
-> 1684 model = super(Word2Vec, cls).load(*args, **kwargs)
1685 # update older models
1686 if hasattr(model, 'table'):
/opt/jupyter-notebook/.local/lib/python2.7/site-packages/gensim/utils.pyc in load(cls, fname, mmap)
246 compress, subname = SaveLoad._adapt_by_suffix(fname)
247
--> 248 obj = unpickle(fname)
249 obj._load_specials(fname, mmap, compress, subname)
250 return obj
/opt/jupyter-notebook/.local/lib/python2.7/site-packages/gensim/utils.pyc in unpickle(fname)
909 with smart_open(fname) as f:
910 # Because of loading from S3 load can't be used (missing readline in smart_open)
--> 911 return _pickle.loads(f.read())
912
913
AttributeError: 'module' object has no attribute 'defaultdict'
我想這可能是一些與「pretrained/model」格式有關的問題,您可以使用Doc2Vec來保存一個並加載以測試它是否有效 – linpingta
嘗試從GitHub庫中更新gensim。這個錯誤在6天前得到修復。 https://github.com/RaRe-Technologies/gensim/issues/853 –
似乎正是我所需要的:模型似乎通過Python 3保存,並且我試圖用Python 2加載它。但是,在我從GitHub倉庫更新gensim後,沒有任何改變... – fremorie