Neural Network Compression

From David's Wiki
Revision as of 21:47, 2 February 2021 by David (talk | contribs)
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

Brief survey on neural network compression techniques.

Pruning

Sensitivity Methods

The idea here is to measure how sensitive each weight (i.e. connection) or neuron is.
I.e., if you remove the neuron, how will it change the output?
Typically, weights are pruned by zeroing them out and freezing them.

In general, the procedure is

  1. Train the network with a lot of parameters.
  2. Compute sensitivity for each parameter.
  3. Delete low-saliency parameters.
  4. Continue training and repeat pruning until the number of parameters is low enough or error is too high.

Sometimes, pruning can also increase accuracy and improve generalization.

  • Mozer and Smolensky (1988)[1] use a gate for each neuron. Then the sensitivity and be estimated with the derivative w.r.t the gate.
  • Karnin[2] estimates the sensitivity by monitoring the change in weight during training.
  • LeCun e al. present Optimal Brain Damage [3] which uses the

Redundancy Methods

  • Srinivas and Babu[4] propose a pair-wise similarity on each neuron: \(\displaystyle s = \Vert a_j^2 \Vert_1 \Vert W_i - W_j \Vert^2_{2}\) where \(\displaystyle a_j\) is the vector of weights on neuron j at the layer above and \(\displaystyle W\) are neuron weights. This combines a weight metric and a similarity metric into one sensitivity metric. When a neuron is pruned, the matrix for the current and next layers need to be updated.

Quantization

There are many works which use 8-bit or 16-bit representations instead of the standard 32-bit floats.

Factorization

Libraries

Both Tensorflow and PyTorch have built in libraries for pruning:

These support magnitude-based pruning which zero out small weights.

Resources

Surveys

References

<templatestyles src="Reflist/styles.css" />

  1. Mozer, M. C., & Smolensky, P. (1988). Skeletonization: A technique for trimming the fat from a network via relevance assessment. (NeurIPS 1988). PDF
  2. Karnin, E. D. (1990). A simple procedure for pruning back-propagation trained neural networks. (IEEE TNNLS 1990). IEEE Xplore
  3. LeCun, Y., Denker, J. S., Solla, S. A., Howard, R. E., & Jackel, L. D. (1989, November). Optimal brain damage. (NeurIPS 1989). PDF
  4. Srinivas, S., & Babu, R. V. (2015). Data-free parameter pruning for deep neural networks. PDF