save_quant_retrain_model

Applicability

Product

Supported

Atlas A3 training series products/Atlas A3 inference series products

  • INT8 quantization: √

Atlas A2 training products/Atlas A2 inference products

  • INT8 quantization: √

Atlas 200I/500 A2 inference product

  • INT8 quantization: √

Atlas inference series products

  • INT8 quantization: √

Atlas training products

  • INT8 quantization: √

Description

Inserts operators such as AscendQuant and AscendDequant into the retrained model and generates a model that can be used for both accuracy simulation and inference deployment.

Prototype

1
save_quant_retrain_model(pb_model, outputs, record_file, save_path)

Parameters

Parameter

Input/Output

Description

pb_model

Input

.pb model saved after retraining.

A string.

outputs

Input

Output of the user model

A list of strings, for example, [output1,output2,...].

record_file

Input

File for storing quantization factors. A quantized model file is generated based on the record file and original .pb model file.

A string.

save_path

Input

Model save path.

Must include the prefix of the model name, for example, ./quantized_model/*model.

A string.

Returns

None

Example

1
amct.save_quant_retrain_model(FLAGS.checkpoint_path+'/output_graph.pb',output_node_names, record_file, FLAGS.checkpoint_path+'/resnet50')

The quantized .pb model file can be used for accuracy simulation in the TensorFlow environment or inference on the Ascend AI Processor.

When QAT is performed again, the preceding files output by the API will be overwritten.