# Summary of A Probabilistic Approach to Neural Network Pruning

## Presented by

Stefan Vladusic, Waqas Hamed, Justin D'Astous, Ethan O'Farrell

## Background

High performance neural networks often have a very large number of training parameters. Frankle and Carbin [2] propose the Lottery Ticket Hypothesis that a trained neural network will contain many smaller subnetworks containing the most important logic. When training these subnetworks in isolation after the initialization, they can acheive similar accuracy compared to the original network. Ramanujan et al [10] further proposes that the subnetworks can achieve similar accuracy without having to be further trained. However, finding these lottery tickets inside a large neural network is computationally expensive (NP hard in general).

There has been little research on the theoretical guarantees of pruning. This study, A Probabilistic Approach to Neural Network Pruning by Xin Qian and Diego Klabjan [18], focuses on the theoretical results from creating subnetworks by pruning weights. It covers pruning random weights in Fully Connected Networks (FCNs) and Convolutional Neural Networks (CNNs) as well as pruning weights based on their magnitude in FCNs. It does not cover the theoretical implications of pruning entire neurons.

## Literature Review

Empirical Network Pruning: The theory on neural network pruning has transitioned from pruning individual connections based on the loss function [5] to pruning connections based on its magnitude [3]. Papers began to focus on pruning entire neurons [4] or convolution channels [6that could be redundant. Recently, the focus has shifted to instead find a smaller subnetwork inside an overparameterized network with comparable predictive power and prune the rest.

Theoretical Study of Network Pruning: Some research has looked into pruning FCNs with ReLU activation. Their work used the idea that a single ReLU neuron can be approximated using a two-hidden-layer neural network with constant width [8][9]. Other methods of pruning currently being researched are a greedy optimization based pruning method [11] and sampling-based pruning algorithms based on sensitivity scores [1][7].

## Pruning

Deep neural networks can become computationally intensive and memory intensive. To tackle that people have employed neural network pruning in recent years. Pruning is simply the act of reducing the weights of a neural network layer. As explained in detail later, pruning can reduce the complexity of the network while keeping the difference in errors of the original neural network and the pruned neural network minimal. Pruning is either performed on individual weights or on entire neurons (whole column in a weight matrix). In the paper, only pruning individual weights has been discussed.

Pruning is a 3-step process that can be summarized as:

1. Train the network.
2. Prune the network.
3. Re-train the network.

The figure [3] below demonstrates both pruning individual weights/synapses and pruning neurons.

Magnitude based pruning refers to reducing the number of weights in a layer based on the weight’s absolute value. The intuition behind this is that the weights with values close to zero, do not contribute significantly to the predictive ability of the network. To perform this, a mask matrix M, which has the same size as the weight matrix, is used. M has all entries equal to 1, except elements corresponding to weights to be pruned where the entry is instead 0. These weights are selected based on their magnitude. In the pruned network, the mask is multiplied element-wise with the weight matrix before re-training.

Random pruning also uses a mask matrix M. The weights to be pruned are decided randomly selected.

## Pruning Fully Connected Networks

### A Brief Comment on Our Review

The paper we are reviewing relies on proofs that are both technical and lengthy. The authors use 9 lemmas spanning order statistics, random matrix theory and probability theory in order to prove the main results. Furthermore, the authors provide 4 pruning techniques (with corresponding proofs). However these proofs are all quite similar. Consequently, we will not present the technical details of the proof, since we feel this would be too long and too complicated for a (relatively) short review. Instead, we hope to:

1. Clarify the terminology used by the authors.
2. Explain how this terminology intuitively describes pruning technique.
3. Explain why the assumptions made in the magnitude based pruning technique are required.
4. Briefly comment on the validity of these assumptions.

### Clarifying the Objects of Study

In [18] the authors define the following standard objects and notation:

• $L+1$ denotes the depth the neural network (alternatively there are $L$ hidden layers), with $l\in\{1,...,L\}$ indexing hidden layers (the input layer is denoted with $l=0$).
• $d_{l}$ denotes the number of nodes in the hidden layer $l\in\{1,...,L\}$.
• Let $v\in\mathbb{R}^{d_{l}}$. The $L_{0}$ norm of $v$ is denoted $||v||_{0}$, and specifies the number of non-zero entries in $v$. The $L_{2}$ norm of $v$ is denotes $||v||_{2}$, which denotes the Euclidean “standard” norm $||v||_{2}=\sqrt{v^{T}v}$.
• Let $A\in\mathbb{R}^{m\times n}$ . The vectorization of $A$ is defined as follows: $\text{vec}(A)=\left[A_{1,1},...,A_{1,n},...,A_{m,1},...,A_{m,n}\right]^{T}\in\mathbb{R}^{m\cdot n}$ where we use $\cdot"$ to dinstinguish $\mathbb{R}^{m\cdot n}$ (a set of vectors with dimension $m\cdot n$) from $\mathbb{R}^{m\times n}$ (the set of linear operators $V$ such that $V:\mathbb{R}^{m}\rightarrow\mathbb{R}^{n})$.
• Let $A\in\mathbb{R}^{m\times n}$ , then the induced 2-norm of $A$ is defined as $||A||_{2}=\sigma_{\max}(A)$ where $\sigma_{\max}(A)$ denotes the largest singular value of $A$.
• If $A,B\in\mathbb{R}^{m\times n}$ then $A\circ B$ denotes the Hadamard product so that $\left[A\circ B\right]_{ij}=A_{ij}B_{ij};\ i\in\{1,...,m\},\ j\in\{1,...,n\}$.
• $\mathcal{U}[a,b]$ denotes the uniform distribution on $[a,b]$ and $\mathcal{N}(\mu,\Sigma)$ denotes the multivariate normal distribution.
• $\sigma_{l}:\mathbb{R\rightarrow\mathbb{R}},\ l\in\{1,...,L\}$ is the activation function associated with layer $l$. $W_{l}^{*}\in\mathbb{R}^{d_{l}\times d_{l-1}},\ l\in\{0,...,L\}$ denotes the weight matrix of this layer.
• The target network is defined as $F(x)=W_{l}^{*}\sigma_{l-1}(W_{l-1}^{*}\sigma_{l-1}(\cdots W_{2}^{*}\sigma_{1}(W_{1}^{*}x)))$ and is just the functional representation of a neural network. It is assumed activation functions act componentwise on their inputs.

The authors in [18] also define the some more idiosyncratic objects:

• The number of weights in the $l^{\text{th}}$ layer is denoted $D_{l}:=d_{l}d_{l-1}$.
• A mask matrix $M\in[0,1]^{m\times n}$ is just an $m\times n$ valued matrix whose entries are identically $0$ or $1$.
• A pruned weight matrix corresponding to the weight matrix $W_{l}^{*}$ of a fully connected network is given by $W_{l}=M_{l}\circ W_{l}^{*}$ where $M_{l}$ is a mask matrix.
• A pruning $f(x)$ of the target network $F(x)$ is defined as $f(x)=W_{l}\sigma_{l-1}(W_{l-1}\sigma_{l-1}(\cdots W_{2}\sigma_{1}(W_{1}x)))$.
• Let $W_{l}$ be a pruned weight matrix for layer $l$. The compression ratio of layer $l$ is defined as $\gamma_{l}:=\frac{||\text{vec}(W_{l})||_{0}}{D_{l}}$
• $f(x)$ is said to be $\epsilon$-close to $F(x)$ iff $\sup_{x\in\mathcal{B}_{d_{0}}}||f(x)-F(x)||\lt \epsilon$ where $\mathcal{B}_{d_{0}}:=\left\{ x\in\mathbb{R}^{d_{0}}\ |\ ||x||_{2}\leq1\right\}$ denotes the $d_{0}$ unit-ball with the Euclidean norm.

### Intuition Behind the Objects

In general the objects defined above are either defined to formally express a pruned network, or to provide some measure of efficacy for a given pruned network. In the former category are mask matrices, pruned weight matrices and prunings of the target network. The latter consists of $\epsilon$-closeness and the compression ratio.

Intuitively, the mask matrix can be thought of as a “switch” which allows or blocks certain components of the previous layer to modify the input of the activation’s output. This can be seen with a toy example. Suppose that for some layer $l$ of a FCN, the weight function is given as $W_{l}^{*}=\left[\begin{array}{cc} 1 & 2\\ 4 & 5\\ 7 & 8 \end{array}\right]$ Now consider the mask matrix $M_{l}=\left[\begin{array}{cc} 1 & 1\\ 0 & 1\\ 1 & 0 \end{array}\right]$ This mask induces a pruned weight matrix $W_{l} = M_{l} \circ W^*_{l} = \left[\begin{array}{cc} 1 & 1\\ 0 & 1\\ 1 & 0 \end{array}\right]\circ\left[\begin{array}{cc} 1 & 2\\ 4 & 5\\ 7 & 8 \end{array}\right]=\left[\begin{array}{cc} 1 & 2\\ 0 & 5\\ 7 & 0 \end{array}\right]$ Now suppose the input from the previous layer is given by $x=[x_{1},x_{2}]^{T}$, then $z:=W_{l}x=\left[\begin{array}{c} x_{1}+2x_{2}\\ 5x_{2}\\ 7x_{1} \end{array}\right]\neq\left[\begin{array}{c} x_{1}+2x_{2}\\ 4x_{1}+5x_{2}\\ 7x_{1}+8x_{2} \end{array}\right]=W_{l}^{*}x=:z^{*}$

Hence we see that the activation input is different between the pruned and unpruned weight matrices. But crucially, the $i^{\text{th}}$ component $x_{i}$ of the weight matrix input $x$ has no influence of the $j^{\text{th}}$ component $z_{j}$ of the activation input $z$ if $\left[M_{l}\right]_{ji}=0$, and the influence of the $x_{i}$ on $z_{j}$ is unaltered when $\left[M_{l}\right]_{ji}=0$. This is what we mean by saying $M_{l}$ switches — or prunes — connections in a weight matrix. Its effect is tantamount to severing a connection between the inputs of a weight matrix (or, outputs of the previous layer’s activation function) and the inputs of the layer’s activation function.

Since $W_{l}=M\circ W_{l}^{*}$, $W_{l}$ is naturally interpreted as the weight matrix of a network that has had its connections pruned by $M_{l}$. Finally, $f(x)$ has the same same general architecture as $F(x)$ — its activation functions, number of layers and nodes. If every $M_{ji}=0$ for some $i\in d_{l-1}$, then it is clear the value of $x_{i}^{l}$ will make no contribution to the vector $z$. However, strictly speaking the $i^{\text{th}}$node of layer $l-1$ is still part of the network — it’s just vestigial. are the same as $F(x)$. The only difference between $f(x)$ and $F(x)$ is that the former uses pruned weight vectors, while the latter uses the original, unpruned weight vectors. In this way it is clear that $f(x)$ just represents a subnetwork of $F(x)$ which has had its connections pruned as specified by the matrices $M_{l},\ l\in\{1,...,L\}$.

The discussion above makes it clear that $f(x),M_{l},W_{l}$ are defined as a means of formally representing a pruned subnetwork of some FCN. However, we ultimately wish to describe the efficacy of the pruned network. Of particular imporance are how much “smaller” the pruned subnetwork is compared to its corresponding FCN, and the discrepancies between the predictions of the pruned and FC network.

The former notion is captured by the compression ratio $\gamma_{l}$. In particular this ratio can be interpreted as the percentage of connections that are left in the neural network after pruning. So if $\gamma_{l}=0.18$, only $18\%$ of the original connections between layers $l$ and $l-1$ remain. This can be seen in the extreme cases where a masking matrix $M_{l}$ for some FC weight matrix $W_{l}^{*}$ has entries that are identically $0$ or $1$. In the first case, it is clear that every entry of $M_{l},\ \text{vec}(M_{l})$ are zero, so that $||\text{vec}(W_{l})||_{0}=0$ and $\gamma_{l}=||\text{vec}(W_{l})||_{0}/D_{l}=0$. Meanwhile if $M_{l}$ has all entries equal to $1$ then $||\text{vec}(M_{l}\circ W_{l}^{*})||_{0}=d_{l}d_{l-1}=D_{k}$ so $\gamma_{l}=1$. Every other case falls in between these two extremes, since $0\leq||\text{vec}(W_{l})||_{0}\leq D_{k}$ clearly.

Returning to our toy example, we see that $W_{l}=\left[\begin{array}{cc} 1 & 2\\ 0 & 5\\ 7 & 0 \end{array}\right]\Rightarrow||\text{vec}(W_{l})||_{0}=4\Rightarrow\gamma_{l}=\frac{||\text{vec}(W_{l})||_{0}}{d_{l}\cdot d_{l-1}}=\frac{4}{3\cdot2}=0.667$ which again describes the percentage of connections which have not been pruned.

Finally $\epsilon$-closeness can be interpreted as a guaranteed accuracy. By selecting $x\in\mathcal{B}_{d_{0}}$ that causes the largest discrepancy between the values of $f(\cdot)$ and $F(\cdot)$, $f(\cdot)$ and $F(\cdot)$ are $\epsilon$-close if even in the worst case scenario the discrepancy between the $f(\cdot)$ and $F(\cdot)$ is less than $\epsilon$.

With this intuition in mind, the goal of a pruning algorithm can be cast in a more technical form: given a FCN $F(\cdot)$, find a set of masking matrices $\{M_{1},...,M_{l}\}$ so that for a given $\epsilon$ the corresponding pruned network $f(\cdot)$ has the smallest possible compression ratios $\{\gamma_{1},...,\gamma_{l}\}$ while remaining $\epsilon$-close to $F(\cdot)$.

### The Main Result: Magnitude Based Pruning

Specifying a pruned subnetwork $f(\cdot)$ is tantamount to determining a set of masking matrices. One approach for selecting $M$ considered by the authors is so-called “magnitude based pruning”. This method begins by ordering the entries of a FC weight matrix $W_{l}^{*}$ by magnitude $|W_{l}^{*}|_{i_{1},j_{1}}\leq\cdots\leq|W_{l}^{*}|_{i_{d_{l}},j_{d_{l}}}$ where $i_{n},j_{n}$ refer to the index of the entry in $W_{l}^{*}$ with the $n^{\text{th}}$ smallest magnitude ($n\in\{1,...,D_{k}\}$). Then $M_{l}$ is set by first specifying the desired compression ratio $\gamma_{l}$, setting the entries of $M_{l}$ corresponding to the smallest $\lfloor\gamma_{l}D_{l}\rfloor$ components of $W_{l}^{*}$ to zero, and the rest to one.

With this context, we state the main result of the paper:

Theorem 1 of [18] : Suppose that $F$ is a FC target network and that:

(i)
$\sigma_{l}$ is Lipschitz continuous with constant $K_{l},\ \forall l\in\{1,...,L\}$
(ii)
$d:=\min\{d_{1},...,d_{L-1}\}\geq\max\{d_{0},d_{L}\}$
(iii)
The entries in $W_{k}^{*}$ are iid following $\left[W_{k}^{*}\right]_{i,j}\sim\mathcal{U}\left[-\frac{K}{\sqrt{\max\{d_{l},d_{l-1}\}}},\frac{K}{\sqrt{\max\{d_{l},d_{l-1}\}}}\right];\ i\in\{1,...,d_{l}\},i\in\{1,...,d_{l-1}\}$ where $K$ is a fixed positive constant.

Let $\epsilon,\delta\gt 0,\alpha\in(0,1)$ so that $d\geq\max\left\{ C_{1}^{\frac{1}{\alpha}},\left(\frac{C_{2}}{\epsilon}\right)^{\frac{1}{\alpha}},\left(\frac{C_{3}}{\delta}\right)^{\frac{1}{\alpha}},C_{4}+C_{5}\log\left(\frac{1}{\delta}\right)\right\}$ For $C_{1},...,C_{5}$ depending on values of $l,K_{l}$. Then with probability at least $1-\delta$, the subnetwork $f$ of $F$ with mask $M=\left\{ M_{1},...,M_{L}\ |\ M_{l}\in\{0,1\}^{d_{l}\times d_{l-1}}\right\}$ pruning the smallest $\lfloor D_{l}^{1-\alpha}\rfloor$ entries of $W_{l}^{*},\ l\in\{1,...,L\}$ based on magnitude is $\epsilon$-close to $F$, i.e. $\sup_{x\in\mathcal{B}_{d_{0}}}||f(x)-F(x)||_{2}\leq\epsilon$

We note that $\alpha$ effectively specifies $\gamma_{l}=D_{l}^{-\alpha}$, so although it is not directly stated in the theorem, the compression ratio is present.

### Unpacking and Justifying the Assumptions:

As previously stated we will not provide a full characterization of the proof. Instead, we clarify why the authors made the three assumptions that appear in the theorem.

First, we comment on the Lipschitz continuity of $\sigma_{k}$. For our purposes function $g:\mathbb{R}^{n}\rightarrow\mathbb{R}^{n}$ is Lipschitz continuous iff $||g(x)-g(y)||_{2}\leq K||x-y||_{2}$ for any $x,y\in\mathbb{R}^{n}$ (see for more details on Lipschitz continuity). The intuition when $g:\mathbb{R}\rightarrow\mathbb{R}$ is that $g$ is Lipschitz just when its value never changes quicker than the function $h(x)=Kx$. The reason the activation functions are Lipschitz continuous is just because the proof of the main theorem relies on random matrix theory and, in particular, the probability that the 2-norms of random matrices exceed certain bounds. By ensuring that $||\sigma(z_{l}^{*})-\sigma(z_{l})||_{2}\leq K_{l}||W_{l}^{*}x_{l}-W_{l}x_{l}||_{2}$ the authors are able to extend the results of bounding the difference between vectors under random matrices, to bounding the difference between vectors under non-linear transformations (see section 4 of [5]). So, the results of random matrix theory can be harnessed to prove the main results.

The second assumption is largely used to provide tighter bounds on the probabilities given in the relevant theorem. As such its role is mostly related to technical details (again see section 4 of [5]).

Finally, the third assumption is by far the most important assumption. As previously mentionned, the main proof relies on a few theorems imported from random matrix theory . In particular, the main theorem heavily relies on , of which the former only applies to independent, mean zero random matrices with finite fourth moments and the latter which applies to (sub-Gaussian) iid random matrices.

The first two assumptions are easy to justify. For the first assumption, we note that in practice most activation functions are Lipschitz continuous. For instance, the sigmoid, ReLU, tanh and softmax functions are all Lipschitz continuous with $K=1$ (see ). So this is clearly a reasonable assumption. The second assumption is even easier to justify. One can simply set all $d\geq\max\{d_{0},d_{l}\}$ when designing the architecture of the FCN $F(\cdot)$. Hence the first two assumptions will almost always hold in practice.

Unlike the first two assumptions, the third assumption is not evidently the case. Assuming that $\{W_{l}^{*}\ |\ l\in\{1,...,L\}\}$ are i.i.d. random is a priori strong assumption with no particularly strong justification. Given this difficulty, the authors essentially argue that because (1) there is no way to effectively measure how close weights are to independence, (2) some literature — namely — suggests that weights in a trained network do not deviate strongly from their initial values. However, in our view it is clear that this constitutes only a partial, if not promising, justification for assumption (iii). Consequently the most important assumption for the main theorem is also the least secure.

## Future Works

Issues raised by Balock et al argue that in general, the community surrounding neural network pruning research suffers from a lack of standardization. Definitions tend to be ambiguous and comparisons are difficult to make between performances of different pruning algorithms. Overall, this sector will see much more research and focus in the near future. This paper is a foundation for theoretical works regarding pruning both FCNs and CNNs. Importantly, since nearly all network architectures can be replaced by some combination of FCNs and CNNs, this paper has application in pruning many different architectures. Applying these results to past works by Frankle & Carbin in 2018 gives a method to determine an upper bound on the number of weights available for pruning in a given layer in order to maintain the desired error margin.

The paper’s analysis assumes that weights in the original network are independent. This assumption is not ideal, especially in CNNs. While the paper’s appendix discusses ways around it, no solution could be found. The authors suggest that an in-depth study of this assumption is warranted in the future. Another topic not explored fully is using gradients of the weights in the original network to determine more optimal pruning algorithms.

## References

[1] Baykal, C., Liebenwein, L., Gilitschenski, I., Feldman, D., and Rus, D. Sipping neural networks: Sensitivity informed provable pruning of neural networks. arXiv preprint arXiv:1910.05422, 2019b.

[2] Frankle, J. and Carbin, M. The lottery ticket hypothesis: Finding sparse, trainable neural networks. International Conference on Learning Representations, 2018.

[3] Han, S., Mao, H., and Dally, W. J. Deep compression: Compressing deep neural networks with pruning, trained quantization and Huffman coding. International Conference on Learning Representations, 2015a.

[4] Hu, H., Peng, R., Tai, Y.-W., and Tang, C.-K. Network trimming: A data-driven neuron pruning approach towards efficient deep architectures. arXiv preprint arXiv:1607.03250, 2016.

[5] LeCun, Y., Denker, J. S., Solla, S. A., Howard, R. E., and Jackel, L. D. Optimal brain damage. Advances in Neural Information Processing Systems, volume 2, pp. 598–605, 1989

[6] Li, H., Kadav, A., Durdanovic, I., Samet, H., and Graf, H. P. Pruning filters for efficient convnets. International Conference on Learning Representations, 2016.

[7] Liebenwein, L., Baykal, C., Lang, H., Feldman, D., and Rus, D. Provable filter pruning for efficient neural networks. International Conference on Learning Representations, 2020

[8] Pensia, A., Rajput, S., Nagle, A., Vishwakarma, H., and Papailiopoulos, D. Optimal lottery tickets via subset sum: Logarithmic over-parameterization is sufficient. Advances in Neural Information Processing Systems, 33, 2020.

[9] Orseau, L., Hutter, M., and Rivasplata, O. Logarithmic pruning is all you need. Advances in Neural Information Processing Systems, 33, 2020.

[10] Ramanujan, V., Wortsman, M., Kembhavi, A., Farhadi, A., and Rastegari, M. What’s hidden in a randomly weighted neural network? Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11893–11902, 2020

[11] Ye, M., Gong, C., Nie, L., Zhou, D., Klivans, A., and Liu, Q. Good subnetworks provably exist: Pruning via greedy forward selection. In International Conference on Machine Learning, pp. 10820–10830, 2020a.

[12] Ye, M., Wu, L., and Liu, Q. Greedy optimization provably wins the lottery: Logarithmic number of winning tickets is enough. arXiv preprint arXiv:2010.15969, 2020b.

[13] Blalock, D., Ortiz, J.J.G., Frankle, J., Guttag, J. What is the State of Neural Network Pruning?. arXiv preprint arXiv:2003.03033, 2020.

[14] Yu Bai and Jason D. Lee. Beyond linearization: On quadratic and higher-order approximation of wide neural networks, 2020.

[15] H. A. David and H. N. Nagaraja. Order Statistics. American Cancer Society, 2004.

[16] Jacot, A., Gabriel, F., Hongler, C. Neural tangent kernel: convergence and generalization in neural networks. Proceedings of the 53rd Annual ACM SIGACT Symposium on Theory of Computing, 2021.

[17] Latala, R. Some estimates of norms of random matrices. Proceedings of the American Mathematical Society, 133(5):1273-1282, 2005.

[18] Qian, X., Klabjan, D. A probabilistic approach to neural network pruning, 2021.

[19] Scaman, K., Virmaux, A. Lipschitz regularity of deep neural networks: Analysis and efficient estimation. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, NIPS'18, pages 3839 - 3848. Curran Associates Inc., 2018.

[20] O'Searcoid, M. Metric Spaces. Springer Undergraduate Mathematics Series. Springer, 1 edition, 2006.