当前位置:网站首页>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)
完美撒花
边栏推荐
- Summary of the core steps in the life cycle of beans
- Lake shore M91 fast hall measuring instrument
- Go语言高级
- 学习笔记-JDBC连接数据库操作的步骤
- Lean thinking: source, pillar, landing. I understand it after reading this article
- The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
- Appgallery connect scenario development practice - image storage and sharing
- Dlib+Opencv库实现疲劳检测
- M91 fast hall measuring instrument - better measurement in a shorter time
- Lumiprobe 自由基分析丨H2DCFDA说明书
猜你喜欢
AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
一次SQL优化,数据库查询速度提升 60 倍
The former 4A executives engaged in agent operation and won an IPO
Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency
Today, with the popularity of micro services, how does service mesh exist?
Stanford, salesforce|maskvit: masked vision pre training for video prediction
【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
Helium transmission line of lake shore cryostat
MySQL common graphics management tools | dark horse programmers
Lake Shore continuous flow cryostat transmission line
随机推荐
Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit
微服务大行其道的今天,Service Mesh是怎样一种存在?
Lake shore M91 fast hall measuring instrument
Junit单元测试框架详解
助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
Clean up system cache and free memory under Linux
ES6 summary "suggestions collection" of array methods find(), findindex()
水产行业智能供应链管理平台解决方案:支撑企业供应链数字化,提升企业管理效益
How to operate technology related we media well?
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
How to use the low code platform of the Internet of things for personal settings?
ECS summer money saving secret, this time @ old users come and take it away
记一次 .NET 差旅管理后台 CPU 爆高分析
Stanford, salesforce|maskvit: masked vision pre training for video prediction
[quick application] win7 system cannot run and debug projects using Huawei ide
English语法_形容词/副词3级 -注意事项
Lake Shore 连续流动低温恒温器传输线
Three simple methods of ES6 array de duplication
Lean thinking: source, pillar, landing. I understand it after reading this article
PMP是被取消了吗??