问题
I am calling load like this .
.7/dist-packages/gensim/utils.py", line 912, in
model = gensim.models.Word2Vec.load("F:\\TrialGrounds\\gensimMODEL4\\model4")
model = super(Word2Vec, cls).load(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/gensim/utils.py", line 248, in load
obj = unpickle(fname)
File "/usr/local/lib/python2unpickle
return _pickle.loads(f.read())
AttributeError: 'module' object has no attribute 'call_on_class_only'
The model has split 500mb *2 numpy arrays. Can anyone help me in figuring out this issue
回答1:
Are you by chance trying to load a model made in a later version of gensim into an earlier version? (The call_on_class_only
method, for the purposes of warning about a common error, was only added in December 2016, whereas the latest 0.12.x release was in January 2016.)
While gensim tries to maintain the ability of older models to be loaded in newer versions, the reverse can be quite a bit harder. Try using a later gensim version where you're loading the model.
(If you really needed a workaround, you could possibly load the model in a later version, del model.call_on_class_only
to eliminate the not-strictly-needed function reference, and then re-save... and it might then load()
into an older version. But being version-equivalent and version-up-to-date everywhere would be better.)
来源:https://stackoverflow.com/questions/42753119/error-loading-pretrained-vectors-on-gensim-0-12