Comments (1)
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]
:
import qkeras as qk
qs = qk.quantized_sigmoid(8)
input_value = tf.constant(-1000.0)
output = qs(input_value).numpy()
print('Sigmoid Lower Bound: {0}'.format(output))
input_value = tf.constant(1000.0)
output = qs(input_value).numpy()
print('Sigmoid Upper Bound: {0}'.format(output))
input_value = tf.constant(-0.996)
output = qs(input_value).numpy()
print('Sigmoid Resolution: {0}'.format(output))
Output:
Sigmoid Lower Bound: 0.0
Sigmoid Upper Bound: 1.0
Sigmoid Resolution: 0.00390625
Expected Output:
Sigmoid Lower Bound: 0.0
Sigmoid Upper Bound: 0.99609375
Sigmoid Resolution: 0.00390625
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?
from qkeras.
Related Issues (20)
- Very low accuracy following AutoQKeras notebook and CUDA error HOT 1
- How low precision weights and biases are stored in QKeras? HOT 4
- When I use QKeras: Failed to load in-memory CUBIN: CUDA_ERROR_NO_BINARY_FOR_GPU: no kernel image is available for execution on the device [Op:Abs] HOT 2
- Params not quantized after model_save_quantized_weights function HOT 4
- Only Qconv layer's output tensors are quantized
- Cannot convert 6.0 to EagerTensor of dtype int64
- How do I save an AutoQKeras model that a different script can load?
- `pyparser` vs `pyparsing`
- Can QKeras support Full integer quantization HOT 8
- Add a custom layer with a bitwise operation
- TFLite compatibility
- How can I get the scale of the QAdaptiveActivation layer
- How do keras and qkeras versions correspond to each other?
- Difference between Qkeras model and Keras model HOT 9
- Adding QKeras to conda forge
- TypeError: Could not locate class 'QConv2D'. HOT 4
- Attribute `__name__` missing from QActivation layer
- Unpredictable quantization with quantized_bits and an alpha value of None
- QKeras fails due to missing modules and numpy error message with latest TensorFlow version 2.16.1
- Upgrade to keras v3?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qkeras.