简体   繁体   English

网络量化——为什么需要“zero_point”? 为什么对称量化不需要“零点”?

[英]network quantization——Why do we need "zero_point"? Why symmetric quantization doesn't need "zero point"?

I have Googled all the days, but can't still find the answer I need.我已经用谷歌搜索了很多天,但仍然找不到我需要的答案。 There must be some misunderstandings in my brain.脑子里肯定有什么误会。 Could you please help me out?你能帮帮我吗?

1. Why do we need "zero_point"? 1. 为什么我们需要“zero_point”?

quantization:q=round(r/scale)+zero_point量化:q=round(r/scale)+zero_point

I think that the zero_point (as an offset) shifts the scaled data to a proper position, for examle, in the figure below for unsigned 2 bits quantization, the zero point shifts [-1,2] to {0,1,2,3}我认为 zero_point(作为偏移量)将缩放数据移动到适当的 position,例如,在下图中对于无符号 2 位量化,零点移动 [-1,2] 到 {0,1,2, 3} 在此处输入图像描述

Am I right about this?我说得对吗?

If I am wrong, please help correct me;如果我错了,请帮助纠正我;

If I am right, then zero point is neceesary here (symmetric quantization), and why Jacob in IAO , Section 2.1 said zero-point is for zero-padding?如果我是对的,那么这里需要零点(对称量化),为什么 Jacob 在IAO的第 2.1 节中说零点用于零填充? It seems to me that this is just an outcome, not the root reason?在我看来,这只是一个结果,而不是根本原因?

在此处输入图像描述


2. Why doesn't symmetric quantization need "zero point"? 2、为什么对称量化不需要“零点”?

In Goolge White paper and some blogs, it it said that symmetric quantization dose not need zero point (since zero_point=0):Goolge 白皮书和一些博客中,它说对称量化不需要零点(因为 zero_point=0): 在此处输入图像描述

I can understand it in signed quantization, since both the floating range and the quantized range are symmetric, making zero_point=0.我可以理解为有符号量化,因为浮动范围和量化范围都是对称的,使得 zero_point=0。

However, how can we ignore zero_point in unsigned quantization where the quantized range [0,2^b-1] is not symmetric?但是,我们如何在量化范围 [0,2^b-1] 不对称的无符号量化中忽略 zero_point? Under this situation, it seems to me that we must have a positive zero point to shift the scaled data to the range [0, 2^b-1] as the figure below:在这种情况下,在我看来,我们必须有一个正零点才能将缩放后的数据移动到 [0, 2^b-1] 范围内,如下图所示:

在此处输入图像描述

I haven't found or got definitive answe yet.我还没有找到或得到明确的答案。

But I convince myself as follow:但我说服自己如下:

1.Why do we need "zero_point"? 1.为什么我们需要“zero_point”?

The zero_point is definitely an offset or bias, shifting the scaled data to a proper position. There should be no doubts about it. zero_point 绝对是一个偏移量或偏差,将缩放后的数据移动到适当的 position。对此应该没有疑问。

But what "the motivation" that Jocab methioned is that "Z is of the same tye as quantized q", instead of "having a zero point".但 Jocab 提到的“动机”是“Z 与量化的 q 是同一类型”,而不是“具有零点”。 The former makes sure the real "0" is quantized without error, thus when inferring in the quantized manner, it is the zero point (the same type as q) that is padded (instead of the value "0") in zero_padding (wihout error).前者确保真正的“0”被无误地量化,因此在以量化方式推断时,在zero_padding(没有错误)。

  1. Why doesn't symmetric quantization need "zero point"?为什么对称量化不需要“零点”?

I think the "if signed" and "if un-signed" in the formulas (7)-(9) of white paper are talking about the signs of x, ie, the real, unquantized, floating-point values, instead of the quantized one.我认为白皮书公式(7)-(9)中的“if signed”和“if un-signed”说的是x的符号,即实数,未量化的浮点值,而不是量化一个。 This means, signed floating-point values are quantized to signed fixed-point integer, with zero-point=0;这意味着,带符号的浮点值被量化为带符号的定点 integer,零点 = 0; and unsigned floating-point to unsigned fixed-point interger, with zero-point=0 as well.和无符号浮点到无符号定点整数,零点= 0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM