python - 'KeyedVectors' 对象没有属性 'wv' / 词汇属性已从 Gensim 4.0.0 中的 KeyedVector 中删除
问题描述
word2vec = KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)
print('Found %s word vectors of word2vec' % len(word2vec.vocab))
在 word2vec.vocab 它显示错误,任何人有任何想法来解决它???我试过 word2vec.wc.vocab 和 word2vec.wc,它们不起作用
解决方案
如果你寻找单词'maybe'的向量,而不是使用word2vec.wv.['maybe'],使用word2vec['maybe']。有关更多信息,请改用 KeyedVector 的 .key_to_index 字典、.index_to_key 列表和方法 .get_vecattr(key, attr) 和 .set_vecattr(key, attr, new_val)。见https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4
推荐阅读
- php - 当 php 文件在 URL 中没有 php 扩展名时,PHP Apache 406 不可接受
- shopify - 如何跳过购物车并直接在 Shopify 商店中结账?
- c++ - Clang LLVM 多版本问题
- apache-spark - Pyspark:在when子句中合并条件
- rust - 如何使用 io::Cursor 和字节序读取混合的二进制/文本文件?
- terraform - Terraform aws_flow_log 未添加 IAM 角色 ARN
- c# - LINQ 加入扁平化结果(SelectMany?)
- python - 在 django 社交媒体网络中创建一个赞按钮
- flutter - 如何在 Flutter 中解析没有数组(映射字符串)的 JSON 对象
- vb6 - 根据其他切换按钮状态更改切换按钮状态