Run Model Analysis - 1.1 English

AI Optimizer User Guide (UG1333)

Document ID
UG1333
Release Date
2020-07-07
Version
1.1 English

We have prepared a trained checkpoint and a GraphDef file, now we can start pruning.

Write some shell scripts to call vai_p_tensorflow functions.

WORKSPACE=./models

BASELINE_GRAPH=${WORKSPACE}/mnist.pbtxt
BASELINE_CKPT=${WORKSPACE}/train/model.ckpt-20000
INPUT_NODES="image"
OUTPUT_NODES="softmax_tensor"

action=ana
vai_p_tensorflow \
    --action=${action} \
    --input_graph=${BASELINE_GRAPH} \
    --input_ckpt=${BASELINE_CKPT} \
    --eval_fn_path=est_cnn.py \
    --target="accuracy" \
    --max_num_batches=500 \
    --workspace=${WORKSPACE} \
    --input_nodes="${INPUT_NODES}" \
    --input_node_shapes="1,28,28,1" \
--output_nodes=\"${OUTPUT_NODES}\"

We previously defined an operation of tf.metrics.accuracy named “accuracy” to calculate the accuracy of our model in est_cnn.py:

eval_metric_ops = {
      "accuracy": tf.metrics.accuracy(
          labels=labels, predictions=predictions["classes"])}

We use this operation to evaluate the performance of our model by setting --target=”accuracy”.