Skip to content
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

Different quantization bit configurations for different layers #731

Open
mengna0707 opened this issue Nov 25, 2021 · 1 comment
Open

Different quantization bit configurations for different layers #731

mengna0707 opened this issue Nov 25, 2021 · 1 comment

Comments

@mengna0707
Copy link

Hello,I would like to ask whether larqsupports 8-bit quantization for the first and last layers, and binary quantization for the middle layer?

I have learned that the QAT toolkit of Tensorflow supports 8-bit quantitative perception training.
Can larq be used in combination with this toolkit ?

@mengna0707 mengna0707 changed the title Combined with TensorFlow's QAT toolkit Different quantization bit configurations for different layers Nov 25, 2021
@CNugteren
Copy link
Contributor

Yes that is supported. In fact, it is even recommended in many cases to include some int8 layers. Indeed, typically your first layer can remain int8 to get better accuracy. Here's an example where only the weights are quantized in the first layer, not the activations: https://docs.larq.dev/larq/tutorials/mnist/#create-the-model. In this example, you can replace the kernel_quantizer argumentin the first layer by any quantizer adhering to the lq.quantizers.Quantizer abstract class (or just leave the argument out). Or you can mix in normal tf.keras layers in your network as well, you are not restricted to use only lq. layers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants