You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that the max method of quantized_bits doesn't return correct values.
According to the documentation, the max method should return the largest value which can be represented by the quantizer.
Defining an unsigned 8-Bit quantization with zero integer bits, the quantizer correctly quantizes
the value 1.0 to 0.99609375, which is the larges number which can be represented in this configuration.
But the max method returns 1.0.
I found that, generally, the quantized values seem to not be strictly limited to valid value ranges which are assumed by the specified number of bits in the quantization methods.
Another example of this is quantized_sigmoid using 8 bits in total. In this configuration, I would normally assume that the output of quantized_sigmoid lies in the interval [0.0, 1-(2**-8)] = [0.0, 0.99609375] with a resolution (value step size) of 2**-8 = 0.00390625, because this is what can be represented by using 8 bits.
But, the following code example shows that the value range of quantized_sigmoid is equal to [0.0, 1.0]:
Also, the min and max methods output the interval boundaries of [0.0, 1.0]:
print(qs.min())
print(qs.max())
Output:
0.0
1.0
Expected Output:
0.0
0.99609375
This leads to the fact that for these edge cases the quantization methods output values which are not representable with the specified number of bits. In order to 'encode' the current behaviour of quantized_sigmoid in hardware, it would require 9 bits in total and a special (and inefficient) encoding scheme, in which the upper boundary of 1.0 is also representable.
Similar considerations are also true for the other quantization methods.
Am I missing some details here? Is this the intended quantization scheme in QKeras?
Hi,
I've noticed that the max method of quantized_bits doesn't return correct values.
According to the documentation, the max method should return the largest value which can be represented by the quantizer.
Defining an unsigned 8-Bit quantization with zero integer bits, the quantizer correctly quantizes
the value
1.0
to0.99609375
, which is the larges number which can be represented in this configuration.But the max method returns
1.0
.Minimum example:
Output:
Expected Output:
The text was updated successfully, but these errors were encountered: