Getting the Pruned Model - 2.5 English

Vitis AI Optimizer User Guide (UG1333)

Document ID
Release Date
2.5 English

When the iterative pruning is completed, a sparse model is generated which has the same number of parameters as the original model but with many of them now set to zero.

Call get_slim_model() to remove zeroed parameters and from the sparse model and get a truly pruned model:


input_shape = [28, 28, 1]
input_spec = tf.TensorSpec((1, *input_shape), tf.float32)
runner = IterativePruningRunner(model, input_spec)

By default, the runner uses the latest pruning specification to generate the slim model. You can see what the latest specification file is with the following command:

$ cat .vai/latest_spec
$ ".vai/mnist_ratio_0.5.spec"

If this file does not match your sparse model, you can explicitly specify the file path to be used: