当前位置:网站首页>BN折叠及其量化
BN折叠及其量化
2022-07-06 08:51:00 【cyz0202】
本文介绍量化过程中的BN折叠;
以下图片引用自 Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference
BN折叠
首先介绍BN折叠;BN折叠源自 BN模块在训练阶段和推断阶段的实现差异;
如下图所示:以conv+BN为例,图1为训练阶段的BN,图2为推断阶段的BN
可以证明这样的折叠是合理的,注意图2中的w指的是卷积核;
量化中的BN折叠
对量化来说,尤其是量化感知(伪量化),我们需要保持训练阶段的伪量化和上述图2的推断阶段的量化实现是一致的,因此对训练阶段的CONV+BN二阶段步骤进行折叠,如下图3:
图3的设计思想源自图2,基本思想是训练阶段求的EMA(即图中moment及其前后步骤)拿掉后要和图2一致;
根据图3所示BN折叠,就可以对训练阶段该折叠做后训练量化或者伪量化,如下图4
代码实现
以下代码块来自github distiller,没有完整的上下文实现,感兴趣的读者可以移步阅读
总结
- 以上简要介绍了BN折叠及其量化,思想比较巧妙,感兴趣的读者可以根据文中提到的文献进一步深入阅读,谢谢
- 理解有误的地方欢迎指正
边栏推荐
- Revit 二次开发 HOF 方式调用transaction
- UML圖記憶技巧
- 角色动画(Character Animation)的现状与趋势
- 【剑指offer】序列化二叉树
- Promise 在uniapp的简单使用
- Leetcode: Sword finger offer 42 Maximum sum of continuous subarrays
- Variable length parameter
- [Hacker News Weekly] data visualization artifact; Top 10 Web hacker technologies; Postman supports grpc
- LeetCode:836. Rectangle overlap
- ROS compilation calls the third-party dynamic library (xxx.so)
猜你喜欢
LeetCode:124. 二叉树中的最大路径和
Computer graduation design PHP Zhiduo online learning platform
Current situation and trend of character animation
[OC-Foundation框架]--<Copy对象复制>
LeetCode:498. 对角线遍历
Alibaba cloud server mining virus solution (practiced)
LeetCode:498. Diagonal traversal
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
Detailed explanation of dynamic planning
Light of domestic games destroyed by cracking
随机推荐
Deep analysis of C language data storage in memory
Tdengine biweekly selection of community issues | phase III
目标检测——Pytorch 利用mobilenet系列(v1,v2,v3)搭建yolov4目标检测平台
LeetCode:394. String decoding
[OC-Foundation框架]---【集合数组】
[Hacker News Weekly] data visualization artifact; Top 10 Web hacker technologies; Postman supports grpc
LeetCode:221. 最大正方形
Mongodb installation and basic operation
【嵌入式】使用JLINK RTT打印log
Double pointeur en langage C - - modèle classique
软件压力测试常见流程有哪些?专业出具软件测试报告公司分享
LeetCode:剑指 Offer 42. 连续子数组的最大和
JVM quick start
What is the role of automated testing frameworks? Shanghai professional third-party software testing company Amway
LeetCode:836. 矩形重叠
Detailed explanation of dynamic planning
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
pytorch查看张量占用内存大小
The problem and possible causes of the robot's instantaneous return to the origin of the world coordinate during rviz simulation
[OC]-<UI入门>--常用控件-UIButton