[英]How to load pre-trained model with in gensim and train doc2vec with it?
[英]Unable to load pre-trained gensim Doc2Vec from publication data
我想使用已发表论文中经过培训的 Doc2Vec。
纸
Whalen, R., Lungeanu, A., DeChurch, L. 和 Contractor, N. (2020)。 专利相似性数据和创新指标。 实证法律研究杂志,17(3),615-639。 https://doi.org/10.1111/jels.12261
代码
数据
但是,当尝试加载 model (patent_doc2v_10e.model) 时会出现错误。 编辑:该文件可以从数据存储库(上面的链接)下载。 我不是论文的作者,也不是 model 的创建者。
from gensim.models.doc2vec import Doc2Vec
model = Doc2Vec.load("patent_doc2v_10e.model")
FileNotFoundError: [Errno 2] No such file or directory: 'patent_doc2v_10e.model.trainables.syn1neg.npy'
我是缺少文件还是必须以其他方式加载 model?
文件patent_doc2v_10e.model
来自哪里?
If trying to load that file, it generates such an error about another file with the name patent_doc2v_10e.model.trainables.syn1neg.npy
, then that other file is a necessary part of the full model that should have been created alongside patent_doc2v_10e.model
when该patent_doc2v_10e.model
文件首先是.save()
-持久化到磁盘。
You'll need to go back to where patent_doc2v_10e.model
was created, & find the extra missing patent_doc2v_10e.model.trainables.syn1neg.npy
file (& possibly others also starting patent_doc2v_10e.model…
). 在相同的.save()
中创建的所有此类文件必须一起保存/移动,在相同的文件系统路径中,以便将来的任何.load()
成功。
(此外,如果您自己使用原始数据进行训练,我建议确保使用当前版本的 Gensim。只有较旧的 4.0 之前的版本会创建名称中包含trainables
对象的任何保存文件。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.