当前位置:网站首页>Pytorch loading model error resolution
Pytorch loading model error resolution
2022-06-12 23:44:00 【Cheap sword】
One 、 Problem description
Evaluate the code downloaded from the network , When using automatic model loading “'xxx object has no attribute 'copy'”
Error prompt for .
Two 、 Problem solving
- This problem arises when saving the model
torch.save(mode,"xxxx.pth")
command , Instead oftorch.save(model.state_dict(),"xxx.pth")
, The resulting saved model is not a dictionary type . - We can take the following steps to save it as a dictionary type and then reload it .
pre_weights = torch.load("model.pth") # Load model
torch.save(pre_weights.state_dict(),"/tmp/1.pth") # Save it as /tmp/1.pth file
model.load_state_dict(torch.load("/tmp/1.pth")) # Reload the model file
边栏推荐
- Record 5 - the serial port of stm32f411ceu6 realizes the sending and receiving of fixed length data and variable length data
- Redis realizes SMS verification code login
- Alien Skin Exposure X7调色滤镜插件,RAW后期处理工具
- Hongmeng starts
- Bit_ Binary number
- leaflet如何加载10万条数据
- [redis sentinel] failed listening on port 26379 (TCP) & sentinel mode no response problem solved
- Enterprise wechat H5_ Authentication, PC website, enterprise wechat scanning code, authorized login
- How does idea switch the interface to Chinese
- Is the stock account opened by qiniu Gang safe and reliable?
猜你喜欢
How to publish OSM maps locally and customize the mapping
LeetCode 146. LRU cache
Preparing for the Blue Bridge Cup Day11__ Basic operation of serial port communication
leaflet如何加载10万条数据
Alien skin exposure X7 color filter plug-in, raw post-processing tool
dict和set的基本操作
Enterprise wechat H5_ Authentication, PC website, enterprise wechat scanning code, authorized login
Leetcode 2164. 对奇偶下标分别排序(可以,一次过)
Actual combat | inductance element positioning -- detailed explanation of Halcon and opencv implementation (with source code)
2022 R2 mobile pressure vessel filling test questions and online simulation test
随机推荐
C # graphic tutorial (Fourth Edition) chapter7-7.6.1 virtual and override
2022 questions d'examen pour le personnel de gestion de la sécurité de l'unit é de gestion des produits chimiques dangereux et examen de simulation en ligne
基于Three.js海上风电数字孪生三维效果
TCP与UDP
Leetcode 890 finding and replacing patterns [map] the leetcode path of heroding
Industry reshuffle, a large number of programmers are going to lose their jobs? How can we break the current workplace dilemma
Huawei cloud elastic ECS use [Huawei cloud to jianzhiyuan]
Divicon est toujours utilisé dans le leaflet de l'ère H5?
Redis实现短信验证码登录
數組
RT thread quick start - experience RT thread
Leetcode 2164. 对奇偶下标分别排序(可以,一次过)
妙才周刊 - 5
Face detection: mtcnn
OSM map local publishing - how to generate vector maps of provinces and cities
Common message oriented middleware selection
Operation of simulation test platform for G3 boiler water treatment test questions in 2022
How about opening a securities account in flush? Is it safe or not
Comprehensive analysis of C array
设计消息队列存储消息数据的 MySQL 表格