create_quant_retrain_config
Description
Finds all retrain-capable layers including InnerProduct, Convolution (using a 1-dilated 4 x 4 convolution filter), Deconvolution (using a 1-dilated 4 x 4 convolution filter with group = 1), and AVE Pooling, automatically generates a retrain configuration file, and writes the retrain configuration information of the retrain-capable layers to the configuration file.
Restrictions
None
Prototype
create_quant_retrain_config(config_file, model_file, weights_file, config_defination=None)
Parameters
Parameter |
Input/Return |
Description |
Restrictions |
---|---|---|---|
config_file |
Input |
Directory of the retrain configuration file, including the file name. The existing file (if available) in the directory will be overwritten upon this API call. |
A string. |
model_file |
Input |
Caffe model definition file (.prototxt). |
A string. |
weights_file |
Input |
Weight file of the already-trained Caffe model (.caffemodel). |
A string. |
config_defination |
Input |
Simplified configuration file quant.cfg, which is generated from the retrain_config.proto file. The retrain_config.proto file is stored in /amct_caffe/proto/retrain_config.proto in the AMCT installation path. For details about the available options in the retrain_config.proto file and the generated simplified quantization configuration file quant.cfg, see Simplified Retrain Configuration File. |
Defaults to None. A string. If set to None, a configuration file is generated based on the residual arguments. Otherwise, a configuration file in JSON format is generated based on this argument. |
Returns
None
Outputs
Outputs a retrain configuration file in JSON format. The existing retrain configuration file (if available) in the directory will be overwritten upon this API call. An example is as follows.
{ "version":1, "conv1":{ "retrain_enable":true, "retrain_data_config":{ "algo":"ulq_quantize" }, "retrain_weight_config":{ "algo":"arq_retrain", "channel_wise":true } }, "conv2_1/expand":{ "retrain_enable":true, "retrain_data_config":{ "algo":"ulq_quantize" }, "retrain_weight_config":{ "algo":"arq_retrain", "channel_wise":true } }, "conv2_1/dwise":{ "retrain_enable":true, "retrain_data_config":{ "algo":"ulq_quantize" }, "retrain_weight_config":{ "algo":"arq_retrain", "channel_wise":true } }, }
Example
retrain_simple = 'retrain/retrain.cfg' model_file = 'resnet50_train.prototxt' weights_file = 'ResNet-50-model.caffemodel' config_json_file = './config.json' amct.create_quant_retrain_config(config_json_file, model_file, weights_file, retrain_simple)