文档
注册

create_distill_model

功能说明

蒸馏接口,将输入的待量化压缩的图结构按照给定的蒸馏量化配置文件进行量化处理,在传入的图结构中插入量化相关的算子(数据和权重的蒸馏量化层以及找N的层),返回修改后可用于蒸馏的torch.nn.module模型。

函数原型

compress_model = create_distill_model(config_file, model, input_data)

参数说明

参数名

输入/返回值

含义

使用限制

config_file

输入

用户生成的蒸馏量化配置文件,用于指定模型network中量化层的配置情况和蒸馏结构。

数据类型:string

使用约束:该接口输入的config.json必须和create_distill_config接口输入的config.json一致

model

输入

待进行蒸馏量化的原始浮点模型,已加载权重。

数据类型:torch.nn.module

input_data

输入

模型的输入数据。一个torch.tensor会被等价为tuple(torch.tensor)

数据类型:tuple

compress_model

返回值

修改后可用于蒸馏的torch.nn.module模型。

默认值:None

数据类型:torch.nn.module

返回值说明

量化压缩模型。

函数输出

无。

调用示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import amct_pytorch as amct
# 建立待进行蒸馏量化的网络图结构
model = build_model()
model.load_state_dict(torch.load(state_dict_path))
input_data = tuple([torch.randn(input_shape)])

# 生成压缩模型
compress_model = amct.create_distill_model(
                 config_json_file,
                 model,
                 input_data)
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词