昇腾社区首页
中文
注册

init

产品支持情况

产品

是否支持

Atlas A3 训练系列产品/Atlas A3 推理系列产品

x

Atlas A2 训练系列产品/Atlas 800I A2 推理产品/A200I A2 Box 异构组件

x

Atlas 200I/500 A2 推理产品

Atlas 推理系列产品

Atlas 训练系列产品

功能说明

训练后量化接口,用于初始化AMCT,记录存储量化因子的文件,解析用户模型为图结构graph,供quantize_modelsave_model使用。

函数原型

1
graph = init(config_file, model_file, weights_file, scale_offset_record_file)

参数说明

参数名

输入/输出

说明

config_file

输入

含义:用户生成的量化配置文件。

数据类型:string

model_file

输入

含义:用户Caffe模型的定义文件,格式为.prototxt,与create_quant_config中的model_file保持一致

数据类型:string

使用约束:model_file中包含的用于推理的层,LayerParameter设置满足推理要求,比如BatchNorm层的use_global_stats必须设置为1。

weights_file

输入

含义:用户训练好的Caffe模型文件,格式为.caffemodel,与create_quant_config中的weights_file保持一致。

数据类型:string

scale_offset_record_file

输入

含义:存储量化因子的文件,文件如果不存在,则会被创建,否则会被清空。

数据类型:string

返回值说明

graph:用户模型解析出来的图结构。

调用示例

1
2
3
4
5
6
from amct_caffe import init
# 初始化工具
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")

落盘文件说明:量化因子文件,重新执行量化时,该接口输出的存储量化因子文件将会被覆盖。