Error while loading Word2Vec model in gensim
Fixed the problem with:
from gensim import models
w = models.Word2Vec.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)
print w["queen"]
In order to share word vector querying code between different training algos(Word2Vec, Fastext, WordRank, VarEmbed) the authors have separated storage and querying of word vectors into a separate class KeyedVectors.
Two methods and several attributes in word2vec class have been deprecated.
Methods
- load_word2vec_format
- save_word2vec_format
Attributes
- syn0norm
- syn0
- vocab
- index2word
These have been moved to KeyedVectors class.
After upgrading to this release you might get exceptions about deprecated methods or missing attributes.
To remove the exceptions, you should use
KeyedVectors.load_word2vec_format (instead ofWord2Vec.load_word2vec_format)
word2vec_model.wv.save_word2vec_format (instead of word2vec_model.save_word2vec_format)
model.wv.syn0norm instead of (model.syn0norm)
model.wv.syn0 instead of (model.syn0)
model.wv.vocab instead of (model.vocab)
model.wv.index2word instead of (model.index2word)