create_quant_retrain_model
Applicability
Product |
Supported |
|---|---|
x |
|
x |
|
√ |
|
√ |
|
√ |
Description
Performs quantization on a graph based on the configuration file (config_file), inserts activation and weight fake-quantization layers, and saves the modified network to a new model file.
Prototype
1 | create_quant_retrain_model(model_file, weights_file, config_file, modified_model_file, modified_weights_file, scale_offset_record_file) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
model_file |
Input |
Definition file (.prototxt) of the Caffe model. A string. |
weights_file |
Input |
Weight file (.caffemodel) of the trained Caffe model. A string. |
config_file |
Input |
Quantization configuration file. A string. |
modified_model_file |
Input |
Name of the resultant Caffe model definition file (.prototxt) for storing the inserted QAT layers. A string. |
modified_weights_file |
Input |
Name of the resultant Caffe model weight file (.caffemodel) for storing the inserted QAT layers. A string. |
scale_offset_record_file |
Input |
File for storing quantization factors. A string. |
Returns
None
Example
1 2 3 4 5 6 7 8 | from amct_caffe import amct model_file = 'resnet50_train.prototxt' weights_file = 'ResNet-50-model.caffemodel' modified_model_file = './tmp/modified_model.prototxt' modified_weights_file = './tmp/modified_model.caffemodel' config_json_file = './config.json' scale_offset_record_file = './record.txt' amct.create_quant_retrain_model( model_file, weights_file, config_json_file, modified_model_file, modified_weights_file, scale_offset_record_file) |
Flush files:
- modified_model_file: definition file of the modified model, with QAT layers inserted into the original model.
- modified_weights_file: weight file of the modified model, with QAT layers inserted into the original model.