在gensim 0.12上加载预训练向量时出错 [英] Error loading Pretrained vectors on gensim 0.12

查看:49
本文介绍了在gensim 0.12上加载预训练向量时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在像这样调用负载.

I am calling load like this .

.7/dist-packages/gensim/utils.py",第912行

.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'

该模型已拆分500mb * 2 numpy数组.谁能帮我解决这个问题

The model has split 500mb *2 numpy arrays. Can anyone help me in figuring out this issue

推荐答案

您是否有机会尝试将gensim更高版本中制作的模型加载到早期版本中? (出于警告常见错误的目的,call_on_class_only方法仅在2016年12月添加,而最新的0.12.x版本是在2016年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.)

虽然gensim试图保持将旧模型加载到新版本中的能力,但相反的过程可能要困难得多.尝试使用更高版本的gensim版本加载模型.

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.

(如果您确实需要解决方法,则可以在更高版本中加载模型,del model.call_on_class_only以消除非严格需要的函数引用,然后重新保存...,并且可能 ,然后将load()转换为较旧的版本,但在任何地方都使用等效版本和最新版本会更好.)

(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.)

这篇关于在gensim 0.12上加载预训练向量时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆