Deprecation Warning was issued, so a remedy memo
cofirm.py
from gensim.models import word2vec
model = word2vec.Word2Vec.load("hoge.model")
vec = model["queen"]
print(len(vec.tolist()))
$ python3 confirm.py
confirm.py:7: DeprecationWarning: Call to deprecated `__getitem__` (Method will be removed in 4.0.0, use self.wv.__getitem__() instead).
vec = model["queen"]
300
A warning will appear, so Change the program as follows.
confirm.py
from gensim.models import Word2Vec
model = Word2Vec.load("hoge.model")
vec = model.wv['queen']
print(len(vec.tolist()))
$ python3 confirm.py
300
The warning has disappeared. (´ ▽ `)
Recommended Posts