quantize_model
Description
Quantizes a graph based on the quantization configuration file config_file, inserts quantization layers, and saves the new network to a file.
Prototype
quantize_model(graph, modified_model_file, modified_weights_file)
Parameters
Parameter |
Input/Return |
Description |
Restrictions |
---|---|---|---|
graph |
Input |
Graph parsed from the user model by the init API. |
An AMCT-defined Graph. |
modified_model_file |
Input |
File name of the quantized Caffe model definition file (.prototxt). |
A string. |
modified_weights_file |
Input |
File name of the quantized model weight file (.caffemodel). |
A string. |
Returns
None
Outputs
- Outputs a quantization factor record file by writing the weight quantization factors (scale_w and offset_w) of each quantization layers to scale_offset_record_file passed to the init call.
- Outputs modified_model_file, the definition file of the result model inserted with quantization layers.
- Outputs modified_weights_file, the weight file of the result model inserted with quantization layers.
When quantization is performed again, the existing files in the output directory will be overwritten upon this API call.
Example
from amct_caffe import quantize_model # Quantize the model. quantize_model(graph=graph, modified_model_file="./quantized_model/modified_model.prototxt", modified_weights_file="./quantized_model/modified_model.caffemodel")