当前位置:网站首页>pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
2022-07-01 18:44:00 【hei_hei_hei_】
pickle.load报错【AttributeError: Can’t get attribute ‘Vocabulary’ on <module ‘main’】
背景:在看代码的时候想看看一个pkl文件的文件结构和里面的数据,于是就用pickle.load打开,但是出现了
AttributeError: Can't get attribute 'Vocabulary' on <module '__main__'错误原因:就像我们在保存模型的时候有两种方式,一种是保存整个模型,虽然很大但是使用方便;另一种是只保存了模型的参数,这里加载时就需要先初始化一个模型。这里也是一样的,
msvd_vocab.pkl在加载时也需要找到其依赖的类,而在报错信息中也说明了,需要导入的类是Vocabulary。所以需要在项目中找到类Vocabulary,然后在调用pickle.load('.../msvd_vocab.pkl','rb')的python文件中import该类报错代码
import pickle
with open('.\data\MSVD\msvd_vocab.pkl','rb') as f:
v = pickle.load(f)
# 报错:在demo.py的main中没有‘Vocabulary’模块
AttributeError: Can't get attribute 'Vocabulary' on <module '__main__' from '.../demo.py'>
- 找到‘Vocabulary’类

- 更正
import pickle
from utils.utils import *
with open('.\data\MSVD\msvd_vocab.pkl','rb') as f:
v = pickle.load(f)
完美撒花
边栏推荐
- Qfile read / write file operation in QT
- MySQL common graphics management tools | dark horse programmers
- PostgreSQL varchar[] array type operation
- 宝,运维100+服务器很头疼怎么办?用行云管家!
- Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
- 线程的并行、并发、生命周期
- Lake shore optimag superconducting magnet system om series
- Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
- Helium transmission line of lake shore cryostat
- 太爱速M源码搭建,巅峰小店APP溢价寄卖源码分享
猜你喜欢

Dlib+Opencv库实现疲劳检测

linux下清理系统缓存并释放内存

精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会

Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?

More information about M91 fast hall measuring instrument

Junit单元测试框架详解

微服务大行其道的今天,Service Mesh是怎样一种存在?

Openai video pre training (VPT): action learning based on watching unmarked online videos

Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency

中英说明书丨人可溶性晚期糖基化终末产物受体(sRAGE)Elisa试剂盒
随机推荐
Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency
Summary of cases of players' disconnection and reconnection in Huawei online battle service
Yyds dry inventory ravendb start client API (III)
Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration
Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase
【To .NET】C#集合类源码解析
精益思想:来源,支柱,落地。看了这篇文章就懂了
赋能「新型中国企业」,SAP Process Automation 落地中国
Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?
The former 4A executives engaged in agent operation and won an IPO
网易游戏,激进出海
[6.24-7.1] review of wonderful technical blog posts in the writing community
Mipi interface, DVP interface and CSI interface of camera [easy to understand]
How to operate technology related we media well?
indexof和includes的区别
The difference between indexof and includes
Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
Docker deploy mysql8.0