akoksal/Turkish-Word2Vec

Cannot Load Pretrained Model

fthbrmnby opened this issue · 2 comments

I was following the instructions in the wiki page to load and use saved models, (Section 5) downloaded the pretrained model but it seems like gensim cannot load the model from file. When I try to load model like so:

from gensim.models import KeyedVectors
word_vectors = KeyedVectors.load("trmodel")

I get an error at the word_vectors = KeyedVectors.load("trmodel") line that says:

AttributeError: Can't get attribute 'EuclideanKeyedVectors' on <module 'gensim.models.keyedvectors' from "DIR_OF_keyedvectors.py_UNDER_ANACONDA_SITE_PACKAGES_FOLDER"'

Here is my setup:

  • Python 3.6.4 : Anaconda 64-bit
  • Gensim 3.4.0
  • Ubuntu 17.10 64-bit

I think it's because versions of gensim used for training and loading the model are different, some functions might be changed or deprecated or something. Could you check it out please?

Hello Fatih,
I have upgraded my gensim library to 3.4.0 and changed the output file format. Now, you can download binary file for word vectors and you can load it via this command:

from gensim.models import KeyedVectors
word_vectors = KeyedVectors.load_word2vec_format('trmodel', binary=True)

I have tried with python3.6 and it loaded model without error. I am waiting for your response. Thank you for the feedback.

Yep, that solved it. Thanks!