我使用 Gensim 3.6.0 加载预训练的 Word2Vec,在调用 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.
这是我的代码示例
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'])
最佳答案
错误消息实际上告诉我们使用对象本身,即 model
而不是 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
关于python-3.x - Gensim v3.6.0 Word2Vec DeprecationWarning : Call to deprecated `wv` (Attribute will be removed in 4. 0.0,使用 self 代替),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61944240/