pytorch模型存储的2种实现方法
作者:慢行厚积 时间:2023-10-06 11:37:24
1、保存整个网络结构信息和模型参数信息:
torch.save(model_object, './model.pth')
直接加载即可使用:
model = torch.load('./model.pth')
2、只保存网络的模型参数-推荐使用
torch.save(model_object.state_dict(), './params.pth')
加载则要先从本地网络模块导入网络,然后再加载参数:
from models import AgeModel
model = AgeModel()
model.load_state_dict(torch.load('./params.pth'))
来源:https://www.cnblogs.com/wanghui-garcia/p/11236382.html
标签:pytorch,模型,存储
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
如何使用Iframe实现本页提交?
2010-06-05 12:36:00
Python编程实现凯撒密码加密示例
2021-04-22 01:58:56
MySQL execute、executeUpdate、executeQuery三者的区别
2024-01-23 15:32:11
asp程序运行速度测试
2008-02-11 19:11:00
设计需知:移动网站设计应注意的技术细节
2012-04-20 13:03:23
JAVA使用DBUtils操作数据库
2024-01-18 11:28:36
使用python检测手机QQ在线状态的脚本代码
2023-03-27 02:12:06
CSS3创建惊艳多重边框色
2010-07-23 10:13:00
form表单的submit方法和submit事件
2008-10-15 11:22:00
通俗讲解Python中的五种下划线含义
2023-09-14 04:06:14
![](https://img.aspxhome.com/file/2023/3/121163_0s.png)
Django框架中render_to_response()函数的使用方法
2023-09-03 13:58:49
如何给MD5加上salt随机盐值
2022-01-13 05:32:37
新手如何快速入门Python(菜鸟必看篇)
2021-01-27 01:24:35
![](https://img.aspxhome.com/file/2023/7/133497_0s.jpg)
java连接Oracle数据库的方法解析
2024-01-21 22:12:27
![](https://img.aspxhome.com/file/2023/4/65584_0s.png)
对python3中pathlib库的Path类的使用详解
2023-05-11 23:44:49
![](https://img.aspxhome.com/file/2023/6/102336_0s.jpg)
Python学习之Django的管理界面代码示例
2022-07-16 21:29:07
![](https://img.aspxhome.com/file/2023/2/98992_0s.png)
python实现用户名密码校验
2022-12-14 07:48:33
![](https://img.aspxhome.com/file/2023/4/70684_0s.jpg)
python3 模拟登录v2ex实例讲解
2022-09-23 00:42:53
详解Laravel模型事件和模型事件在Trait中的使用
2023-06-17 17:19:28
Python处理键映射值操作详解
2021-03-21 03:14:53
![](https://img.aspxhome.com/file/2023/5/105255_0s.png)