-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can QKeras support Full integer quantization #111
Comments
Just add the With regards to normalization. You can still normalize it, and then scale it to fit the integer value to which this quantizer is quantizing. Inn this case it is 128. |
@jurevreca12 Thanks for your reply. After I normalize my input, how do I scale it to fit the integer value to which this quantizer is quantizing? (in this case, it should be [-128, 128]) or should I scale the normalized input manually? |
You could just scale it manually, as part of the pre-processing. I don't think there is any built in function in qkeras. |
@jurevreca12 Thanks for your feedback. |
QKeras does support full integer quantization. Where the operations are only: integer multiply, integer add, shift and compare (e.g. calculate ReLU). However QKeras is made for quantization aware training, which does provide better results, but can be a little complicated for beginners. One simple example would be to create a fully-integer network for MNIST. The inputs are ranged between 0-255. So you can set the input quantizer to be |
One additional confusing thing for beginners are scaling factors. For exploring how qkeras works, I recommend setting |
@jurevreca12 I very much appreciate your feedback, and I have learned so much. Thanks a lot. The current problem is that I have no idea about getting the scale of the activations tensor. So, the only problem is to get the scale of the activations tensor. I tried two ways,
So, is there any way that I can get the scale of the activations tensor? |
The scale of the activation tensor is determined by the scale of the two multiplicands: the weights, and the inputs. There is a nice paper from Google that explains this well: https://arxiv.org/pdf/1712.05877.pdf. Btw. In the last answer I said the input quantizer should be |
I know I can get the weight and bias to INT8 by setting:
kernel_quantizer=quantized_bits(bits=8, integer=7, alpha=1)
bias_quantizer=quantized_bits(bits=8, integer=7, alpha=1)
However, sometimes, the input tensor is still float because we have to normalize the input.
So, my question is "Can QKeras support the quantization of input tensor?"
The text was updated successfully, but these errors were encountered: