snowkylin / tensorflow-handbook

简单粗暴 TensorFlow 2 | A Concise Handbook of TensorFlow 2 | 一本简明的 TensorFlow 2 入门指导教程
https://tf.wiki
3.94k stars 841 forks source link

quantized results description #39

Open burui11087 opened 4 years ago

burui11087 commented 4 years ago

Thanks for your great work in advance!

I have some questions about the following description: https://github.com/snowkylin/tensorflow-handbook/blob/3b4abc38f8dfdaba32258b1aa1f726cc95bb7a82/docs/zh/deployment/lite.html#L446 In my daily experiments, I find that the quantized results(accuracy) can go down as well as up when task is classification. So I think it's better to modify this description.

Thanks again.

dpinthinker commented 4 years ago

@burui11087 Could you tell me on which condition the quantized size will be bigger than the original one?

dpinthinker commented 4 years ago

Post-training quantization is a conversion technique that can reduce model size while also improving CPU and hardware accelerator latency, with little degradation in model accuracy. From https://www.tensorflow.org/lite/performance/post_training_quantization

burui11087 commented 4 years ago

Post-training quantization is a conversion technique that can reduce model size while also improving CPU and hardware accelerator latency, with little degradation in model accuracy. From https://www.tensorflow.org/lite/performance/post_training_quantization

I am not a researcher in the direction of model quantization. At first I thought the official description you posted was correct, but after a lot of experiments( a classification task), I found the quantized results could go down as well as up(I can't post my experiment results here because of corporate data security). After discuss with my colleague, we think the quantization operation can be treated as reducing overfitting like L1,L2, but this is just speculation. However I think the official description should be verified again. Maybe I should open a issue in tensorflow github repository.

burui11087 commented 4 years ago

Post-training quantization is a conversion technique that can reduce model size while also improving CPU and hardware accelerator latency, with little degradation in model accuracy. From https://www.tensorflow.org/lite/performance/post_training_quantization

I think that's my fault after reread https://tf.wiki/zh/deployment/lite.html#quantization . I find what you talk about is post-training quantization, it will cause accuracy loss. I use quantization-aware training in my daily work, that will make the accuracy better or worse.

burui11087 commented 4 years ago

@burui11087 Could you tell me on which condition the quantized size will be bigger than the original one?

not quantized size, it's accuracy.

dpinthinker commented 4 years ago

@burui11087 Yes, I just try to talk about post training quantization here.

Thank you for your careful reviewing. I am a beginner in tflite. If you have found any issue in this chapter, or have any idea, please let me know.

dpinthinker commented 4 years ago

@snowkylin maybe we need add training-aware-quantization content later.