Jzz
Jzz
another problem, I use aimet torch simulate quantization, and get the encodings, the quantization simulate acc is good. But when i depoly to snpe(1.43) dsp, the accuracy is poor. so...
> 关于误差,ppq里是看qt_output和fp_output的差距, 是否有实验过:1、qt_output和label的loss;2、qt_output和fp_output与label的loss的差距~? 不同网络loss计算方式不同,构建起来很“麻烦”,有时甚至不知道loss的设计,qat中需考虑任务loss,ptq的话直接衡量cos就行,常规模型cos(fp, int8)>0.99精度都满足,画质类要求更高一些
the same problem that dataloader time is unstable. How did you finally solve it?
客气啦。我理解的量化分为以下步骤, 浮点模型--> 浮点模型clip --> 量化quantize(此处为0-255整数或-128-127)--> 解量化dequantize(此处为量化后的浮点数,但最多只有2^n种浮点表征,即有限浮点数集合)。你所描述的quant_model是dequantize后的模型,所以是浮点。train用dequantize的浮点来模拟inference时的整数,具体你可以读一下这两篇论文。 Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference Quantizing deep convolutional networks for efficient inference: A whitepaper
> > 大佬你好,最近趁着假期在学习大佬的代码收获颇丰,已向周围小伙伴推荐了大佬的代码。但是关于量化过程中我有一点想不明白,训练得到quant_model后(也就是大佬的模型)。 > > :1、我在模型部署阶段,是需要把里面的卷积权值小数乘以255变成整数吗?如果是的话,卷积后的特征图也也是整数,但时当特征图经过BN层时,BN层的值全是浮点小数怎么和特征图进行定点运算呢?即前向推断过程中,即Conv->BN->激活函数,这一样过程,数据是咋流动的呢? > > 2、BN层融合这儿,量化训练后,如果把卷积层和BN层融合,变为新的卷积层后,那么这个卷积层的参数便不再是定点小数了,乘以尺度因子后,它也变不回int型的数吖? > > @jingdonglin @Jzz24 大哥, 你这问题解决了吗? 整个量化的流程可以参照google的量化白皮书,现在的量化框架都是遵循那一套流程。首先拿到fp模型,然后融合bn,然后进行量化。无论离线量化还是finetune量化,都是先融合bn,再量化,我这个git的代码bn处理的不规范
dorefa paper says :'Here we assume the output of the previous layer has passed through a bounded activation function h, which ensures r ∈ [0, 1].' But the paper does...
yes, I think so. in training time, we use simulation quantization, the activation layer inputs is the dequantize result. it's float format.
改一下bit配置测试一下就知道啦
> > �改一下bit配置测试一下就知道啦 > > 感谢回复,我这就准备试一下。在Image net上量化的准确度,位宽为4或者其他位数时,BN层的参数是不是仍然是32位的啊。谢谢! 是的,这里对bn没做处理,仍然是fp32,可以参考一下google whitepaper文章bn的处理