![](/img/trans.png)
[英]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.