当前位置:网站首页>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折叠及其量化,思想比较巧妙,感兴趣的读者可以根据文中提到的文献进一步深入阅读,谢谢
- 理解有误的地方欢迎指正
边栏推荐
- ESP8266-RTOS物联网开发
- 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
- LeetCode:387. The first unique character in the string
- Deep analysis of C language pointer
- 力扣每日一题(二)
- Mongodb installation and basic operation
- The problem and possible causes of the robot's instantaneous return to the origin of the world coordinate during rviz simulation
- 可变长参数
- Philosophical enlightenment from single point to distributed
- [sword finger offer] serialized binary tree
猜你喜欢

Esp8266-rtos IOT development

TCP/IP协议

ESP8266-RTOS物联网开发

Nacos 的安装与服务的注册

Light of domestic games destroyed by cracking

Problems encountered in connecting the database of the project and their solutions

Warning in install. packages : package ‘RGtk2’ is not available for this version of R

vb. Net changes with the window, scales the size of the control and maintains its relative position

MongoDB 的安装和基本操作

【剑指offer】序列化二叉树
随机推荐
C語言雙指針——經典題型
Revit secondary development Hof method calls transaction
Navicat premium create MySQL create stored procedure
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
Using pkgbuild:: find in R language_ Rtools check whether rtools is available and use sys The which function checks whether make exists, installs it if not, and binds R and rtools with the writelines
Roguelike game into crack the hardest hit areas, how to break the bureau?
如何正确截取字符串(例:应用报错信息截取入库操作)
Computer graduation design PHP Zhiduo online learning platform
Visual implementation and inspection of visdom
LeetCode:26. 删除有序数组中的重复项
随手记01
Super efficient! The secret of swagger Yapi
What are the common processes of software stress testing? Professional software test reports issued by companies to share
LeetCode:673. 最长递增子序列的个数
ant-design的走马灯(Carousel)组件在TS(typescript)环境中调用prev以及next方法
目标检测——Pytorch 利用mobilenet系列(v1,v2,v3)搭建yolov4目标检测平台
Marathon envs project environment configuration (strengthen learning and imitate reference actions)
Compétences en mémoire des graphiques UML
Li Kou daily question 1 (2)
LeetCode:劍指 Offer 42. 連續子數組的最大和