create_quant_retrain_config
产品支持情况
产品  | 
是否支持  | 
|---|---|
x  | 
|
x  | 
|
√  | 
|
√  | 
|
√  | 
功能说明
量化感知训练接口,根据图的结构找到所有可量化的层,自动生成量化配置文件,并将可量化层的量化配置信息写入配置文件。
约束说明
无。
函数原型
1 | create_quant_retrain_config(config_file, model_file, weights_file, config_defination=None)  | 
参数说明
参数名  | 
输入/输出  | 
说明  | 
|---|---|---|
config_file  | 
输入  | 
含义:待生成的量化感知训练配置文件存放路径及名称。 如果存放路径下已经存在该文件,则调用该接口时会覆盖已有文件。 数据类型:string  | 
model_file  | 
输入  | 
含义:Caffe原始模型的定义文件,格式为.prototxt。 数据类型:string  | 
weights_file  | 
输入  | 
含义:Caffe原始模型权重文件,格式为.caffemodel。 数据类型:string  | 
config_defination  | 
输入  | 
含义:基于retrain_config_caffe.proto文件生成的简易配置文件quant.cfg,*.proto文件所在路径为:AMCT安装目录/amct_caffe/proto/。*.proto文件参数解释以及生成的quant.cfg简易量化配置文件样例请参见量化感知训练简易配置文件。 默认值:None。 数据类型:string 使用约束:当取值为None时,使用输入参数生成配置文件;否则根据量化感知训练简易配置文件参数config_defination生成JSON格式的配置文件。  | 
返回值说明
无
调用示例
1 2 3 4 5 6  | from amct_caffe import amct 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)  | 
落盘文件说明:
生成一个JSON格式的量化感知训练配置文件(重新执行量化感知训练时,该接口输出的配置文件将会被覆盖)。样例如下,参数解释请参见量化配置文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33  | { "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 } }, }  | 
父主题: 量化感知训练接口