当前位置:网站首页>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
边栏推荐
- 自动获取结构体内部成员变量的位置偏移
- Deep learning neural network: implementation method of convolution [direct method (no loss of precision), GEMM (matrix multiplication, no loss of precision), FFT (Fourier transform, loss of precision)
- SAP 业务技术平台(BTP) 上的 Business Rules Service 使用介绍
- Lower interest rates lead to higher bond prices
- Model over fitting - solution (II): dropout
- 2022年G3锅炉水处理考题模拟考试平台操作
- scala中的隐式转换和隐式参数讲解与实践
- KConfig
- Message queue directory
- leaflet中如何通过透明度控制layerGroup的显示隐藏
猜你喜欢

RT thread quick start - experience RT thread

Design a MySQL table for message queue to store message data

〖Kubernetes指南④〗Pod快速入门

2202-簡曆制作

Redis实现短信验证码登录

Operation of simulation test platform for G3 boiler water treatment test questions in 2022

AWS lambda: how to store secrets to external APIs- AWS Lambda: How to store secret to external API?

The Milvus graphical management tool Attu is coming!

dict和set的基本操作

Access static variables within class in swift
随机推荐
It is meaningful to define genus, and D can use it to explain semantics
Introduction to message oriented middleware (message queue)
最全预告!华为云精彩议程火速收藏
M_ 8: Design a MySQL table for message queue to store message data
Comprehensive analysis of C array
线上真实排队系统重构案例分享——实战篇
Divicon est toujours utilisé dans le leaflet de l'ère H5?
2022年6月11日记:王老师的春天,混入
妙才周刊 - 5
Talent Weekly - 5
基于Three.js海上风电数字孪生三维效果
NCF 的Dapr应用实例的运行
利率降低导致债券价格上涨
Zhengzhou University of light industry -- development and sharing of harmonyos pet health system
2022 R2 mobile pressure vessel filling test questions and online simulation test
The programmer has worked for 7 years. At the age of 31, he has no choice but to deliver takeout. I really don't want you to go through his journey again
C # graphic tutorial (Fourth Edition) chapter7-7.6.1 virtual and override
2022 electrician (elementary) operation certificate examination question bank and online simulation examination
Deep learning neural network: implementation method of convolution [direct method (no loss of precision), GEMM (matrix multiplication, no loss of precision), FFT (Fourier transform, loss of precision)
〖Kubernetes指南④〗Pod快速入门