Gensim v3.6.0 Word2Vec DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead)

Viewed 2736

I was using Gensim 3.6.0 for loading a pre-trained Word2Vec and it showed the following error while calling model.wv.

/anaconda/envs/python36/lib/python3.6/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead).
  """Entry point for launching an IPython kernel.

Here is my code sample

import gensim
model = gensim.models.KeyedVectors.load_word2vec_format('/path/to/file/my-vec-300d-v2', binary=False)
print(model.wv['hello'].shape)
print(model.wv['hello']) 
1 Answers

The error message actually tells us using the object itself i.e. model rather than model.wv.

print(model['hello'].shape) # instead of model.wv['hello'].shape which is deprecated
print(model['hello']) # instead of model.wv['hello'] which is deprecated
Related