666DZY666 / micronet

micronet, a model compression and deploy lib. compression: 1、quantization: quantization-aware-training(QAT), High-Bit(>2b)(DoReFa/Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference)、Low-Bit(≤2b)/Ternary and Binary(TWN/BNN/XNOR-Net); post-training-quantization(PTQ), 8-bit(tensorrt); 2、 pruning: normal、regular and group convolutional channel pruning; 3、 group convolution structure; 4、batch-normalization fuse for quantization. deploy: tensorrt, fp32/fp16/int8(ptq-calibration)、op-adapt(upsample)、dynamic_shape
MIT License
2.21k stars 478 forks source link

模型量化的问题 #72

Open huangshenneng opened 3 years ago

huangshenneng commented 3 years ago

您好,感谢大佬共享的代码。但是在阅读量化Quantizer的源码时发现,大佬进行了 量化/反量化,正常不是只量化就行了吗?量化后再反量化,不是只相当于变换权重值的范围而已嘛?还是说反量化后方便与模型训练?

JSnobody commented 3 years ago

@huangshenneng 做量化,再做反量化是必须的啊,因为下一个量化的算子缩放范围是不一样的了。除非所有的缩放是一个因子,那么可以中间不做反量化,最后输出fp32的时候再做反量化。