QuantizationConfig

Class to configure the quantization process of the model:

class model_compression_toolkit.core.QuantizationConfig(activation_error_method=QuantizationErrorMethod.MSE, weights_error_method=QuantizationErrorMethod.MSE, relu_bound_to_power_of_2=False, weights_bias_correction=True, weights_second_moment_correction=False, input_scaling=False, softmax_shift=False, shift_negative_activation_correction=True, activation_channel_equalization=False, z_threshold=inf, min_threshold=1.52587890625e-05, l_p_value=2, linear_collapsing=True, residual_collapsing=True, shift_negative_ratio=0.05, shift_negative_threshold_recalculation=False, shift_negative_params_search=False, concat_threshold_update=False, activation_bias_correction=False, activation_bias_correction_threshold=0.0, custom_tpc_opset_to_layer=None)

A class that encapsulates all the different parameters used by the library to quantize a model.

Examples

You can create a quantization configuration to apply to a model. For example, to quantize a model’s weights and activations using thresholds, with weight threshold selection based on MSE and activation threshold selection using NOCLIPPING (min/max), while enabling relu_bound_to_power_of_2 and weights_bias_correction, you can instantiate a quantization configuration like this:

>>> import model_compression_toolkit as mct
>>> qc = mct.core.QuantizationConfig(activation_error_method=mct.core.QuantizationErrorMethod.NOCLIPPING, weights_error_method=mct.core.QuantizationErrorMethod.MSE, relu_bound_to_power_of_2=True, weights_bias_correction=True)