tlt.models.image_classification.torchvision_image_classification_model.TorchvisionImageClassificationModel.quantize

TorchvisionImageClassificationModel.quantize(output_dir, dataset, config=None, overwrite_model=False)

Performs post training quantization using the Intel Neural Compressor on the model using the dataset. The dataset’s training subset will be used as the calibration data and its validation or test subset will be used for evaluation. The quantized model is written to the output directory.

Parameters
  • output_dir (str) – Writable output directory to save the quantized model

  • dataset (ImageClassificationDataset) – dataset to quantize with

  • config (PostTrainingQuantConfig) – Optional, for customizing the quantization parameters

  • overwrite_model (bool) – Specify whether or not to overwrite the output_dir, if it already exists (default: False)

Returns

None

Raises
  • FileExistsError – if the output_dir already has a model.pt file

  • ValueError – if the dataset is not compatible for quantizing the model