1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Word2Vec: Warning対処] DeprecationWarning: Call to deprecated `__getitem__` (Method will be removed in 4.0.0, use self.wv.__getitem__() instead).

Last updated at Posted at 2020-06-10

DeprecationWarningが出たので対処法メモ

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

警告が出てくるので,
プログラムを以下のように変更する.

confirm.py
from gensim.models import Word2Vec

model = Word2Vec.load("hoge.model")
vec = model.wv['queen']
print(len(vec.tolist()))
$ python3 confirm.py
300

警告が消えました.(´▽`)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?