当前位置:网站首页>【Pytorch】量化
【Pytorch】量化
2022-06-24 13:02:00 【.云哲.】
#-*- coding:utf-8 -*-
import torch
#量化仅可用cpu
model = ResNet().cpu()
model = torch.load_state_dict(torch.load(weights))
#Specify quantization configuration
#在这一步声明了对称量化或非对称量化,及量化bit数
#如下代码中采用了默认的非对称量化,及8bit
model.qconfig = torch.quantization.default_qconfig
model = torch.quantization.prepare(model)
#Convert to quantized model
model = torch.quantization.convert(model)
#Save model, 保存后模型的size显著减小,但性能损失相对较大
#故,建议考虑量化感知训练
torch.save(model.state_dict(), "path.pt")
边栏推荐
- Maximum path sum in binary tree [handle any subtree, then handle the whole tree]
- Jerry's seamless looping [chapter]
- Mysql题目篇
- One click to generate University, major and even admission probability. Is it so magical for AI to fill in volunteer cards?
- Jupiter notebook operation
- Defoaming
- **Puzzling little problem in unity - light and sky box
- 遠程辦公之:在家露營辦公小工具| 社區征文
- 取消冒泡
- 如何在物联网低代码平台中进行任务管理?
猜你喜欢
随机推荐
A review of text contrastive learning
杰理之串口接收 IO 需要设置数字功能【篇】
HarmonyOS.2
Docker安装redis
2022年质量员-设备方向-岗位技能(质量员)复训题库及在线模拟考试
Kotlin coroutine context and scheduler
Tupu software is the digital twin of offshore wind power, striving to be the first
在线文本实体抽取能力,助力应用解析海量文本数据
CONDA and pip commands
markdown/LaTeX中在字母下方输入圆点的方法
【从零开始学zabbix】一丶Zabbix的介绍与部署Zabbix
Jericho turns on shouting in all modes to increase mic automatic mute [chapter]
leetcode:1504. 统计全 1 子矩形的个数
kotlin 协程通道
npm包【详解】(内含npm包的开发、发布、安装、更新、搜索、卸载、查看、版本号更新规则、package.json详解等)
数学之英文写作——基本中英文词汇(几何与三角的常用词汇)
返回新列表
厨卫电器行业B2B交易协同管理平台开发,优化企业库存结构
greendao使用问题
知识经济时代,教会你做好知识管理