当前位置:网站首页>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)
完美撒花
边栏推荐
- 洞态在某互联⽹⾦融科技企业的最佳落地实践
- Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
- Gameframework eating guide
- JS find the next adjacent element of the number in the array
- Viewing the whole ecology of Tiktok from a macro perspective
- Prices of Apple products rose across the board in Japan, with iphone13 up 19%
- Solution: you can ping others, but others can't ping me
- Cache problems after app release
- The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables
- 【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
猜你喜欢

Lumiprobe phosphide hexaethylene phosphide specification

Huawei game failed to initialize init with error code 907135000

Lake shore M91 fast hall measuring instrument

Lake Shore - crx-em-hf low temperature probe station

Getting started with kubernetes command (namespaces, pods)

Lake shore optimag superconducting magnet system om series

寶,運維100+服務器很頭疼怎麼辦?用行雲管家!

Lumiprobe 亚磷酰胺丨六甘醇亚磷酰胺说明书

Lumiprobe cell imaging study PKH26 cell membrane labeling kit

从零开始学 MySQL —数据库和数据表操作
随机推荐
记一次 .NET 差旅管理后台 CPU 爆高分析
Mipi interface, DVP interface and CSI interface of camera [easy to understand]
DTD建模
Lake Shore - crx-em-hf low temperature probe station
学习笔记-JDBC连接数据库操作的步骤
助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
Write it down once Net travel management background CPU Explosion Analysis
[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?
Lake shore optimag superconducting magnet system om series
CDGA|从事通信行业,那你应该考个数据管理证书
Gameframework eating guide
English语法_形容词/副词3级 -注意事项
Redis 实现限流的三种方式
[pytorch record] distributed training dataparallel and distributeddataparallel of the model
数商云:从规划到落地,五矿集团如何快速构建数字化发展新格局?
Qfile read / write file operation in QT
【6.24-7.1】写作社区精彩技术博文回顾
Docker deploy mysql8.0
June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse