簡體   English   中英

伯特 Model 沒有加載泡菜

[英]Bert Model not loading with pickle

我為 NER 訓練了一個 Bert Model。 它運行良好(顯然需要時間來學習)。 我用pickle保存了 model 作為

with open('model_pkl', 'wb') as file:
     pickle.dump(model, file)

當我嘗試加載這個已保存的 model 時,出現以下錯誤。 AttributeError: Can't get attribute 'BertModel' on <module '__main__' from '<input>'> 此方法適用於列表、字典等,但在pytorch model 上產生錯誤。我正在使用python 3.8.10

嘗試使用torch.save 和 torch.load

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM