init

Function Usage

Initializes AMCT, saves the quantization factor record file, and parses the user model into a graph that can be used for the quantize_model and save_model calls.

Prototype

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

Command-line options

Option

Input/Return

Description

Restriction

config_file

Input

Quantization configuration file generated by the user.

A string

model_file

Input

Caffe model definition file (.prototxt), the same as model_file passed to the create_quant_config call.

A string

Restriction: For layers for inference, the settings in LayerParameter in model_file must meet inference requirements. For example, use_global_stats of the BatchNorm layer must be set to 1.

weights_file

Input

Already-trained Caffe model file (.caffemodel), the same as weights_file passed to the create_quant_config call.

A string

scale_offset_record_file

Input

Path of the file that stores quantization factors. If the file exists in the path, it will be overwritten.

A string

graph

Returns

Graph structure parsed from the user model.

An AMCT-defined Graph.

Returns

graph: graph structure parsed from the user model.

Outputs

A quantization factor record file (scale_offset_record_file).

When quantization is performed again, the preceding file output by the API will be overwritten.

Examples

1
2
3
4
5
6
from amct_caffe import init
Initializing the Tool
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")