Michael Zhu and Suyog Gupta, ["To prune, or not to prune: exploring the efficacy of pruning for model compression"](https://arxiv.org/pdf/1710.01878), 2017 NIPS Workshop on Machine Learning of Phones and other Consumer Devices<br>
Michael Zhu and Suyog Gupta, ["To prune, or not to prune: exploring the efficacy of pruning for model compression"](https://arxiv.org/pdf/1710.01878), 2017 NIPS Workshop on Machine Learning of Phones and other Consumer Devices<br>
<br>
<br>
After completing sensitivity analysis, decide on your pruning schedule.
After completing sensitivity analysis, decide on your pruning schedule.
## Table of Contents
## Table of Contents
1.[Implementation of the gradual sparsity function](#Implementation-of-the-gradual-sparsity-function)
1.[Implementation of the gradual sparsity function](#Implementation-of-the-gradual-sparsity-function)
## Implementation of the gradual sparsity function
## Implementation of the gradual sparsity function
The function ```sparsity_target``` implements the gradual sparsity schedule from [[1]](#zhu-gupta):<br><br>
The function ```sparsity_target``` implements the gradual sparsity schedule from [[1]](#zhu-gupta):<br><br>
<b><i>"We introduce a new automated gradual pruning algorithm in which the sparsity is increased from an initial sparsity value $s_i$ (usually 0) to a final sparsity value $s_f$ over a span of $n$ pruning steps, starting at training step $t_0$ and with pruning frequency $\Delta t$."</i></b><br>
<b><i>"We introduce a new automated gradual pruning algorithm in which the sparsity is increased from an initial sparsity value $s_i$ (usually 0) to a final sparsity value $s_f$ over a span of $n$ pruning steps, starting at training step $t_0$ and with pruning frequency $\Delta t$."</i></b><br>
Pruning happens once at the beginning of each epoch, until the duration of the pruning (the number of epochs to prune) is exceeded. After pruning ends, the training continues without pruning, but the pruned weights are kept at zero.
Pruning happens once at the beginning of each epoch, until the duration of the pruning (the number of epochs to prune) is exceeded. After pruning ends, the training continues without pruning, but the pruned weights are kept at zero.
When using the Automated Gradual Pruning (AGP) schedule, you may want to visualize how the pruning schedule will look as a function of the epoch number. This is called the *sparsity function*. The widget below will help you do this.<br>
When using the Automated Gradual Pruning (AGP) schedule, you may want to visualize how the pruning schedule will look as a function of the epoch number. This is called the *sparsity function*. The widget below will help you do this.<br>
There are three knobs you can use to change the schedule:
There are three knobs you can use to change the schedule:
-```duration```: this is the number of epochs over which to use the AGP schedule ($n\Delta t$).
-```duration```: this is the number of epochs over which to use the AGP schedule ($n\Delta t$).
-```initial_sparsity```: $s_i$
-```initial_sparsity```: $s_i$
-```final_sparsity```: $s_f$
-```final_sparsity```: $s_f$
-```frequency```: this is the pruning frequency ($\Delta t$).
-```frequency```: this is the pruning frequency ($\Delta t$).