python-3.x - Gensim v3.6.0 Word2Vec DeprecationWarning : Call to deprecated `wv` (Attribute will be removed in 4. 0.0,使用 self 代替)

标签 python-3.x gensim word2vec

我使用 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/

相关文章:

python - 如何用gensim过滤掉语料库中tf-idf低的词?

python - 如何使用带有 gensim 的 TF-IDF 或 LSA 计算单词相似度?

python - 为什么这个条件不引发异常 : (1==0 <= 1/0) == False? Python 如何解析这个?

Python 3、easy_install、pip 和 pypi

nlp - 我们可以以分布式方式构建 word2vec 模型吗?

python - 如何将大型数据集加载到 gensim word2vec 模型

nlp - 跨多种语言的语义相似性

machine-learning - 结合其他模型中的单词创建词向量模型

python - 无法导入 pygal_maps_world.World

python - 作为 Snakefile 输出的函数或字典理解