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

#### 产品支持情况

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


#### 功能说明

量化感知训练接口，根据用户设置的量化配置文件对图结构进行量化处理，该函数在config_file指定的层插入数据和weights伪量化层，将修改后的网络存为新的模型文件。


#### 函数原型

```
create_quant_retrain_model(model_file, weights_file, config_file, modified_model_file, modified_weights_file, scale_offset_record_file)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| model\_file | 输入 | 含义：用户Caffe模型的定义文件，格式为.prototxt。 数据类型：string |
| weights\_file | 输入 | 含义：用户训练好的Caffe模型权重文件，格式为.caffemodel。 数据类型：string |
| config\_file | 输入 | 含义：量化配置文件。 数据类型：string |
| modified\_model\_file | 输入 | 含义：文件名，用于存储插入量化感知训练层的Caffe模型定义文件（格式为.prototxt）。 数据类型：string |
| modified\_weights\_file | 输入 | 含义：文件名，用于存储插入量化感知训练层的Caffe模型权重文件（格式为.caffemodel）。 数据类型：string |
| scale\_offset\_record\_file | 输入 | 含义：存储量化因子的文件。 数据类型：string |


#### 返回值说明

无


#### 调用示例

```
from amct_caffe import amct
model_file = 'resnet50_train.prototxt'
weights_file = 'ResNet-50-model.caffemodel'
modified_model_file = './tmp/modified_model.prototxt'
modified_weights_file = './tmp/modified_model.caffemodel'
config_json_file = './config.json'
scale_offset_record_file = './record.txt'
amct.create_quant_retrain_model( model_file, weights_file, config_json_file,  modified_model_file, modified_weights_file, scale_offset_record_file)
```

落盘文件说明：

- modified_model_file：修改后模型的定义文件，在原始模型上插入了量化感知训练层。
- modified_weights_file：修改后模型的权重文件，在原始模型上插入了量化感知训练层。
