当前位置:网站首页>【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")
边栏推荐
- Convolution kernel and characteristic graph visualization
- 一个团队可以既做项目又做产品吗?
- Harmony os. (2)
- 2022煤矿瓦斯抽采操作证考试题及模拟考试
- pip uninstall all packages except builtin package
- Jerry's serial port receiving IO needs to set the digital function [chapter]
- 2022年氟化工艺考试模拟100题及答案
- Usage of multimeter
- 二叉树中最大路径和[处理好任意一颗子树,就处理好了整个树]
- Activity lifecycle
猜你喜欢

厨卫电器行业B2B交易协同管理平台开发,优化企业库存结构
![[5g NR] 5g NR system architecture](/img/78/6db70c18887c7a3920843d1cb4bdf3.png)
[5g NR] 5g NR system architecture

【从零开始学zabbix】一丶Zabbix的介绍与部署Zabbix

puzzle(016.2)指画星河
![Maximum path sum in binary tree [handle any subtree, then handle the whole tree]](/img/d0/91ab1cc1851d7137a1cab3cf458302.png)
Maximum path sum in binary tree [handle any subtree, then handle the whole tree]

Convolution kernel and characteristic graph visualization

Puzzle (016.2) finger painting Galaxy

Kunpeng arm server compilation and installation paddlepaddle

Mit-6.824-lab4a-2022 (ten thousand words explanation - code construction)

融云通信“三板斧”,“砍”到了银行的心坎上
随机推荐
【深度学习】NCHW、NHWC和CHWN格式数据的存储形式
2022 coal mine gas drainage operation certificate examination questions and simulation examination
npm包【详解】(内含npm包的开发、发布、安装、更新、搜索、卸载、查看、版本号更新规则、package.json详解等)
Harmony os. (2)
文本对比学习综述
2022起重信号司索工(建筑特殊工种)复训题库及答案
Three efficient programming skills of go language
杰理之无缝循环播放【篇】
【R语言数据科学】(十四):随机变量和基本统计量
群晖向阿里云OSS同步
Docker installation redis
Baidu map API drawing points and tips
位于相同的分布式端口组但不同主机上的虚拟机无法互相通信
数学之英文写作——基本中英文词汇(几何与三角的常用词汇)
Rasa 3. X learning series - it is a great honor to be a source code contributor of Rasa contributors, and to build and share the rasa community with rasa source code contributors all over the world!
SAP Marketing Cloud 功能概述(三)
HarmonyOS-3
win10系统问题
js去除字符串空格
[R language data science] (XIV): random variables and basic statistics