nncf.tensorflow.quantization.algorithm#

Classes#

QuantizationController

Controller for the quantization algorithm in TensorFlow.

class nncf.tensorflow.quantization.algorithm.QuantizationController(target_model, config, op_names)[source]#

Bases: nncf.common.compression.BaseCompressionAlgorithmController

Controller for the quantization algorithm in TensorFlow.

Parameters:
property scheduler: nncf.api.compression.CompressionScheduler[source]#

The compression scheduler for this particular algorithm combination.

Return type:

nncf.api.compression.CompressionScheduler

property loss: nncf.api.compression.CompressionLoss[source]#

Returns the loss that is always zero since the quantization algorithm is driven by the original loss and does not require additional losses.

Return type:

nncf.api.compression.CompressionLoss

strip_model(model, do_copy=False)[source]#

Strips auxiliary layers that were used for the model compression, as it’s only needed for training. The method is used before exporting the model in the target format.

Parameters:
  • model (tensorflow.keras.Model) – The compressed model.

  • do_copy (bool) – Modify copy of the model, defaults to False.

Returns:

The stripped model.

Return type:

tensorflow.keras.Model

statistics(quickly_collected_only=False)[source]#

Returns a Statistics class instance that contains compression algorithm statistics.

Parameters:

quickly_collected_only (bool) – Enables collection of the statistics that don’t take too much time to compute. Can be helpful for the case when need to keep track of statistics on each training batch/step/iteration.

Return type:

nncf.common.statistics.NNCFStatistics

compression_stage()[source]#

Returns the compression stage. Should be used on saving best checkpoints to distinguish between uncompressed, partially compressed, and fully compressed models.

Returns:

The compression stage of the target model.

Return type:

nncf.api.compression.CompressionStage