What is QKeras and how to use it
masterQKeras is a quantization extension for Keras designed to provide drop-in replacements for standard Keras layers. It allows you to quickly create deep quantized versions of Keras networks by replacing variable-creating layers (like Dense or Conv2D) with their quantized counterparts (like QDense or QConv2D) and applying quantization to arithmetic operations and activations.
To successfully quantize a model, you must:
- Replace variable-creating layers with QKeras equivalents.
- Quantize any layers that perform mathematical operations.
from keras.layers import *
from qkeras import *
# Example of replacing a standard layer with a quantized one
x = QConv2D(18, (3, 3),
kernel_quantizer="stochastic_ternary",
bias_quantizer="ternary", name="first_conv2d")(x)