" 'Word2Vec' object has no attribute 'load_parent_word2vec_format' " error

20 views Asked by At

I am trying to run an old code which uses python 2.7, and since it runs on the slow version of Word2Vec I want to update it to Python3 and when I did so I got this error:

'Word2Vec' object has no attribute 'load_parent_word2vec_format', with updated libraries.

This it the commad that makes the error:

self.model.load_parent_word2vec_format(fname=tmp_fname)

I am trying to find a way to manage this in python3 and be able to run the code.

1

There are 1 answers

0
gojomo On

You don't say which libraries you're using or show the full 'traceback' error you're getting, so it's not certain what code is involved in your error.

load_parent_word2vec_format() is not a word2vec-related method I recognize, though it is similarly-named to the Gensim library metho load_word2vec_format(). The only potential match findable by Google is a customized Word2Vec implementation in this Github project: https://github.com/mims-harvard/ohmnet/tree/master/ohmnet/gensimmod/model

If that's the variant Word2Vec you need to use, you'd have to have that project installed & working in Python 3 – which might be a challenge if the original authors of that project haven't attempted it, or updated the code in 7 years. (From a quick glance at that project, it doesn't look like its special alternative functionality was, even then, implemented via the 'fast' optimized Cython code-paths. So even getting it working wouldn't deliver OhmNet operations at high speed without additional work the original authors didn't seem to do.)

If you just need plain Word2Vec, as if imported from an unaltered gensim package (which works fine in Python 3.x), then you can load plain word2vec word-vector sets using the standard load_word2vec_format() method.