init
Applicability
Product |
Supported |
|---|---|
x |
|
x |
|
√ |
|
√ |
|
√ |
Description
Initializes AMCT, saves the quantization factor record file, and parses the user model into a graph that can be used for the quantize_model and save_model API calls.
Prototype
1 | graph = init(config_file, model_file, weights_file, scale_offset_record_file) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
config_file |
Input |
Quantization configuration file generated by the user. A string. |
model_file |
Input |
Definition file (.prototxt) of the Caffe model. It must be the same as model_file in create_quant_config. A string. Restrictions: For layers for inference, the settings in LayerParameter in model_file must meet inference requirements. For example, use_global_stats of the BatchNorm layer must be set to 1. |
weights_file |
Input |
Trained Caffe model file (.caffemodel). It must be the same as weights_file in create_quant_config. A string. |
scale_offset_record_file |
Input |
Quantization factor record file. The existing file (if any) in the directory will be overwritten. A string. |
Returns
Returns a graph parsed from the model.
Example
1 2 3 4 5 6 | from amct_caffe import init # Initialize the tool. graph = init(config_file="./configs/config.json", model_file="./pretrained_model/model.prototxt", weights_file="./pretrained_model/model.caffemodel", scale_offset_record_file="./recording.txt") |
Flush file: quantization factor record file. If quantization is performed again, the quantization factor record file output by the API will be overwritten.