Commit 23fbfabb by Klin

feat: VGG16: modify README

parent b965e176
# AlexNet_BN 量化说明
# VGG_16 量化说明
+ 结构和AlexNet基本一致,在训练中的每个conv后加了bn层,量化时将conv、bn、relu合并为QConvBNReLu层。
+ 合并之后如果直接和原全精度模型的conv层进行相似度比对,不符合眼里,且拟合效果较差(可见之前commit的README)
+ 措施:将全精度模型的BN层参数fold至Conv层中,参数量和计算量也相应加至Conv层
+ 该方法不会降低全精度模型推理精度(可为全精度模型加入排除BN层的inference方法,使用fold后模型推理验证)
+ 另外测试了分别单独量化Conv和BN层的方案,精度下降较为明显。同时当前大部分量化策略都采用了Conv+BN的方案,融合能够减少运算量,使得模型更为高效。
## 文件改动
## ptq部分
+ 量化结果:
FP32-acc:87.09
![image-20230410030841210](image/image-20230410030841210.png)
+ 数据拟合:
matlab导入数据,选择列向量
+ 加入FP3-FP7前:
+ js_flops - acc_loss
Rational: Numerator degree 2 / Denominator degree 2
- [ ] center and scale
![image-20230410030613387](image/image-20230410030613387.png)
- [x] center and scale
![image-20230410030625395](image/image-20230410030625395.png)
+ model.py
+ 由于层数较多,为了进行快速声明,添加`make_feature/classifier_layers`,从cfg快速获得特征层和分类层
+ 根据特征层和分类层名字列表,从`quantize_feature/classifier_layers`方法快速生成对应量化层
+ 利用`quantize_utils`方法生成量化层对应的`inference/forward/freeze`方法
+ 利用上述方法可以快速进行网络迁移,从文件开头的cfg指定网络模型(非平面结构仍需进一步改进)
+ module.py
+ 由于VGG网络参数量较大,使用原先的`get_neareat_val`方法会导致显存溢出,对其进行分块处理。
+ js_param - acc_loss
Rational: Numerator degree 2 / Denominator degree 2
- [ ] center and scale
![image-20230410030654186](image/image-20230410030654186.png)
- [x] center and scale
![image-20230410030707277](image/image-20230410030707277.png)
+ 加入FP3-FP7后
+ js_flops - acc_loss
Rational: Numerator degree 2 / Denominator degree 2
- [ ] center and scale
![image-20230410030018190](image/image-20230410030018190.png)
- [x] center and scale
![image-20230410030035550](image/image-20230410030035550.png)
## ptq部分
+ js_param - acc_loss
+ 量化结果:
Rational: Numerator degree 2 / Denominator degree 2
![image-20230415131101450](image/VGG16_table.png)
+ [ ] center and scale
![image-20230410030148120](image/image-20230410030148120.png)
+ 拟合结果(仍采用Rational-Fit 且分子分母多项式次数均为2)
+ [x] center and scale
![flops](image/flops.png)
![image-20230410030206554](image/image-20230410030206554.png)
\ No newline at end of file
![param](image/param.png)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment