Now that you have prepared a trained checkpoint and a GraphDef file, you 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}\"
You have previously defined an operation of tf.metrics.accuracy named
“accuracy” to calculate the accuracy of your model in est_cnn.py
:
eval_metric_ops = {
"accuracy": tf.metrics.accuracy(
labels=labels, predictions=predictions["classes"])}
Use this operation to evaluate the performance of your model by setting --target=”accuracy”.