---
title: init
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/devaids/amct/atlasamct_16_0272.html
sourcePath: /source/zh/canncommercial/900/devaids/amct/atlasamct_16_0272.html
indexId: 6d15f325cd606a4f93f214996c2692959f1bbafbfc57e2762da9ef4e2edaafdd65
---
# init

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | x |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | x |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | x |
| Atlas 200I/500 A2 推理产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |


#### 功能说明

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


#### 函数原型

```
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：用户模型解析出来的图结构。


#### 调用示例

```
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")
```

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