Bayesian Compression for Deep Learning

Christos Louizos, Karen Ullrich, Max Welling

Introduction

While deep neural networks have become extremely successful in in a wide range of applications, often exceeding human performance, they remain difficult to apply in many real world scenarios. For instance, making billions of predictions per day comes with substantial energy costs given the energy consumption of common Graphical Processing Units (GPUs). Also, real-time predictions are often about a factor 100100 away in terms of speed from what deep NNs can deliver, and sending NNs with millions of parameters through band limited channels is still impractical. As a result, running them on hardware limited devices such as smart phones, robots or cars requires substantial improvements on all of these issues. For all those reasons, compression and efficiency have become a topic of interest in the deep learning community.

While all of these issues are certainly related, compression and performance optimizing procedures might not always be aligned. As an illustration, consider the convolutional layers of Alexnet, which account for only 4% of the parameters but 91% of the computation . Compressing these layers will not contribute much to the overall memory footprint.

There is a variety of approaches to address these problem settings. However, most methods have the common strategy of reducing both the neural network structure and the effective fixed point precision for each weight. A justification for the former is the finding that NNs suffer from significant parameter redundancy . Methods in this line of thought are network pruning, where unnecessary connections are being removed , or student-teacher learning where a large network is used to train a significantly smaller network .

From a Bayesian perspective network pruning and reducing bit precision for the weights is aligned with achieving high accuracy, because Bayesian methods search for the optimal model structure (which leads to pruning with sparsity inducing priors), and reward uncertain posteriors over parameters through the bits back argument (which leads to removing insignificant bits). This relation is made explicit in the MDL principle which is known to be related to Bayesian inference.

In this paper we will use the variational Bayesian approximation for Bayesian inference which has also been explicitly interpreted in terms of model compression . By employing sparsity inducing priors for hidden units (and not individual weights) we can prune neurons including all their ingoing and outgoing weights. This avoids more complicated and inefficient coding schemes needed for pruning or vector quantizing individual weights. As an additional Bayesian bonus we can use the variational posterior uncertainty to assess which bits are significant and remove the ones which fluctuate too much under approximate posterior sampling. From this we derive the optimal fixed point precision per layer, which is still practical on chip.

Variational Bayes and Minimum Description Length

A fundamental theorem in information theory is the minimum description length (MDL) principle . It relates to compression directly in that it defines the best hypothesis to be the one that communicates the sum of the model (complexity cost LC\mathcal{L}^{C}) and the data misfit (error cost LE\mathcal{L}^{E}) with the minimum number of bits . It is well understood that variational inference can be reinterpreted from an MDL point of view . More specifically, assume that we are presented with a dataset D\mathcal{D} that consists from NN input-output pairs {(x1,y1),…,(xn,yn)}\{(\mathbf{x}_{1},y_{1}),\dots,(\mathbf{x}_{n},y_{n})\}. Let p(D∣w)=∏i=1Np(yi∣xi,w)p(\mathcal{D}|\mathbf{w})=\prod_{i=1}^{N}p(y_{i}|\mathbf{x}_{i},\mathbf{w}) be a parametric model, e.g. a deep neural network, that maps inputs x\mathbf{x} to their corresponding outputs yy using parameters w\mathbf{w} governed by a prior distribution p(w)p(\mathbf{w}). In this scenario, we wish to approximate the intractable posterior distribution p(w∣D)=p(D∣w)p(w)/p(D)p(\mathbf{w}|\mathcal{D})=p(\mathcal{D}|\mathbf{w})p(\mathbf{w})/p(\mathcal{D}) with a fixed form approximate posterior qϕ(w)q_{\phi}(\mathbf{w}) by optimizing the variational parameters ϕ\phi according to:

where H(⋅)\mathcal{H}(\cdot) denotes the entropy and L(ϕ)\mathcal{L}(\phi) is known as the evidence-lower-bound (ELBO) or negative variational free energy. As indicated in eq. 1, L(ϕ)\mathcal{L}(\phi) naturally decomposes into a minimum cost for communicating the targets {yn}n=1N\{y_{n}\}_{n=1}^{N} under the assumption that the sender and receiver agreed on a prior p(w)p(\mathbf{w}) and that the receiver knows the inputs {xn}n=1N\{\mathbf{x}_{n}\}_{n=1}^{N} and form of the parametric model.

By using sparsity inducing priors for groups of weights that feed into a neuron the Bayesian mechanism will start pruning hidden units that are not strictly necessary for prediction and thus achieving compression. But there is also a second mechanism by which Bayes can help us compress. By explicitly entertaining noisy weight encodings through qϕ(w)q_{\phi}(\mathbf{w}) we can benefit from the bits-back argument due to the entropy term; this is in contrast to infinitely precise weights that lead to H(δ(w))=−∞\mathcal{H}(\delta(\mathbf{w}))=-\inftyIn practice this term is a large constant determined by the weight precision.. Nevertheless in practice, the data misfit term LE\mathcal{L}^{E} is intractable for neural network models under a noisy weight encoding, so as a solution Monte Carlo integration is usually employed. Continuous qϕ(w)q_{\phi}(\mathbf{w}) allow for the reparametrization trick . Here, we replace sampling from qϕ(w)q_{\phi}(\mathbf{w}) by a deterministic function of the variational parameters ϕ\phi and random samples from some noise variables ϵ\epsilon:

where w=f(ϕ,ϵ)\mathbf{w}=f(\phi,\epsilon). By applying this trick, we obtain unbiased stochastic gradients of the ELBO with respect to the variational parameters ϕ\phi, thus resulting in a standard optimization problem that is fit for stochastic gradient ascent. The efficiency of the gradient estimator resulting from eq. 2 can be further improved for neural networks by utilizing local reparametrizations (which we will use in our experiments); they provide variance reduction in an efficient way by locally marginalizing the weights at each layer and instead sampling the distribution of the pre-activations.

Related Work

One of the earliest ideas and most direct approaches to tackle efficiency is pruning. Originally introduced by , pruning has recently been demonstrated to be applicable to modern architectures . It had been demonstrated that an overwhelming amount of up to 99,5% of parameters can be pruned in common architectures. There have been quite a few encouraging results obtained by (empirical) Bayesian approaches that employ weight pruning . Nevertheless, weight pruning is in general inefficient for compression since the matrix format of the weights is not taken into consideration, therefore the Compressed Sparse Column (CSC) format has to be employed. Moreover, note that in conventional CNNs most flops are used by the convolution operation. Inspired by this observation, several authors proposed pruning schemes that take these considerations into account or even go as far as efficiency aware architectures to begin with . From the Bayesian viewpoint, similar pruning schemes have been explored at .

Given optimal architecture, NNs can further be compressed by quantization. More precisely, there are two common techniques. First, the set of accessible weights can be reduced drastically. As an extreme example, and trained NN to use only binary or tertiary weights with floating point gradients. This approach however is in need of significantly more parameters than their ordinary counterparts. Work by explores various techniques beyond binary quantization: k-means quantization, product quantization and residual quantization. Later studies extent this set to optimal fixed point and hashing quantization . apply k-means clustering and consequent center training. From a practical point of view, however, all these are fairly unpractical during test time. For the computation of each feature map in a net, the original weight matrix must be reconstructed from the indexes in the matrix and a codebook that contains all the original weights. This is an expensive operation and this is why some studies propose a different approach than set quantization. Precision quantization simply reduces the bit size per weight. This has a great advantage over set quantization at inference time since feature maps can simply be computed with less precision weights. Several studies show that this has little to no effect on network accuracy when using 16bit weights . Somewhat orthogonal to the above discussion but certainly relevant are approaches that customize the implementation of CNNs for hardware limited devices.

Bayesian compression with scale mixtures of normals

Consider the following prior over a parameter ww where its scale zz is governed by a distribution p(z)p(z):

with z2z^{2} serving as the variance of the zero-mean normal distribution over ww. By treating the scales of ww as random variables we can recover marginal prior distributions over the parameters that have heavier tails and more mass at zero; this subsequently biases the posterior distribution over ww to be sparse. This family of distributions is known as scale-mixtures of normals and it is quite general, as a lot of well known sparsity inducing distributions are special cases.

One example of the aforementioned framework is the spike-and-slab distribution , the golden standard for sparse Bayesian inference. Under the spike-and-slab, the mixing density of the scales is a Bernoulli distribution, thus the marginal p(w)p(w) has a delta “spike” at zero and a continuous “slab” over the real line. Unfortunately, this prior leads to a computationally expensive inference since we have to explore a space of 2M2^{M} models, where MM is the number of the model parameters. Dropout , one of the most popular regularization techniques for neural networks, can be interpreted as positing a spike and slab distribution over the weights where the variance of the “slab” is zero . Another example is the Laplace distribution which arises by considering p(z2)=Exp(λ)p(z^{2})=\text{Exp}(\lambda). The mode of the posterior distribution under a Laplace prior is known as the Lasso estimator and has been previously used for sparsifying neural networks at . While computationally simple, the Lasso estimator is prone to “shrinking" large signals and only provides point estimates about the parameters. As a result it does not provide uncertainty estimates, it can potentially overfit and, according to the bits-back argument, is inefficient for compression.

For these reasons, in this paper we will tackle the problem of compression and efficiency in neural networks by adopting a Bayesian treatment and inferring an approximate posterior distribution over the parameters under a scale mixture prior. We will consider two choices for the prior over the scales p(z)p(z); the hyperparameter free log-uniform prior and the half-Cauchy prior, which results into a horseshoe distribution. Both of these distributions correspond to a continuous relaxation of the spike-and-slab prior and we provide a brief discussion on their shrinkage properties at Appendix C.

One potential choice for p(z)p(z) is the improper log-uniform prior : p(z)∝∣z∣−1p(z)\propto|z|^{-1}. It turns out that we can recover the log-uniform prior over the weights ww if we marginalize over the scales zz:

This alternative parametrization of the log uniform prior is known in the statistics literature as the normal-Jeffreys prior and has been introduced by . This formulation allows to “couple" the scales of weights that belong to the same group (e.g. neuron or feature map), by simply sharing the corresponding scale variable zz in the joint priorStricly speaking the result of eq. 4 only holds when each weight has its own scale and not when that scale is shared across multiple weights. Nevertheless, in practice we obtain a prior that behaves in a similar way, i.e. it biases the variational posterior to be sparse.:

where W\mathbf{W} is the weight matrix of a fully connected neural network layer with AA being the dimensionality of the input and BB the dimensionality of the output. Now consider performing variational inference with a joint approximate posterior parametrized as follows:

where αi\alpha_{i} is the dropout rate of the given group. As explained at , the multiplicative parametrization of the approximate posterior over z\mathbf{z} suffers from high variance gradients; therefore we will follow and re-parametrize it in terms of σzi2=μzi2αi\sigma^{2}_{z_{i}}=\mu^{2}_{z_{i}}\alpha_{i}, hence optimize w.r.t. σzi2\sigma^{2}_{z_{i}}. The lower bound under this prior and approximate posterior becomes:

Under this particular variational posterior parametrization the negative KL-divergence from the conditional prior p(W∣z)p(\mathbf{W}|\mathbf{z}) to the approximate posterior qϕ(W∣z)q_{\phi}(\mathbf{W}|\mathbf{z}) is independent of z\mathbf{z}:

where σ(⋅)\sigma(\cdot), m(⋅)m(\cdot) are the sigmoid and softplus functions respectivelyσ(x)=(1+exp⁡(−x))−1\sigma(x)=(1+\exp(-x))^{-1}, m(x)=log⁡(1+exp⁡(x))m(x)=\log(1+\exp(x)) and k1=0.63576k_{1}=0.63576, k2=1.87320k_{2}=1.87320, k3=1.48695k_{3}=1.48695. We can now prune entire groups of parameters by simply specifying a threshold for the variational dropout rate of the corresponding group, e.g. log⁡αi=(log⁡σzi2−log⁡μzi2)≥t\log\alpha_{i}=(\log\sigma^{2}_{z_{i}}-\log\mu^{2}_{z_{i}})\geq t. It should be mentioned that this prior parametrization readily allows for a more flexible marginal posterior over the weights as we now have a compound distribution, qϕ(W)=∫qϕ(W∣z)qϕ(z)dzq_{\phi}(\mathbf{W})=\int q_{\phi}(\mathbf{W}|\mathbf{z})q_{\phi}(\mathbf{z})d\mathbf{z}; this is in contrast to the original parametrization and the Gaussian approximations employed by . Furthermore, this approach generalizes the low variance additive parametrization of variational dropout proposed for weight sparsity at to group sparsity (which was left as an open question at ) in a principled way.

At test time, in order to have a single feedforward pass we replace the distribution over W\mathbf{W} at each layer with a single weight matrix, the masked variational posterior mean:

to asess the bit precision of each weight in the weight matrix. More specifically, we employed the mean variance across the weight matrix W^\hat{\mathbf{W}} to compute the unit round off necessary to represent the weights. This method will give us the amount significant bits, and by adding 3 exponent and 1 sign bits we arrive at the final bit precision for the entire weight matrix W^\hat{\mathbf{W}}Notice that the fact that we are using mean-field variational approximations (which we chose for simplicity) can potentially underestimate the variance, thus lead to higher bit precisions for the weights. We leave the exploration of more involved posteriors for future work.. We provide more details at Appendix B.

2 Group horseshoe with half-Cauchy scale priors

Another choice for p(z)p(z) is a proper half-Cauchy distribution: C+(0,s)=2(sπ(1+(z/s)2))−1\mathcal{C}^{+}(0,s)=2(s\pi(1+(z/s)^{2}))^{-1}; it induces a horseshoe prior distribution over the weights, which is a well known sparsity inducing prior in the statistics literature. More formally, the prior hierarchy over the weights is expressed as (in a non-centered parametrization):

where τ0\tau_{0} is the free parameter that can be tuned for specific desiderata. The idea behind the horseshoe is that of the “global-local" shrinkage; the global scale variable ss pulls all of the variables towards zero whereas the heavy tailed local variables ziz_{i} can compensate and allow for some weights to escape. Instead of directly working with the half-Cauchy priors we will employ a decomposition of the half-Cauchy that relies upon (inverse) gamma distributions as this will allow us to compute the negative KL-divergence from the scale prior p(z)p(\mathbf{z}) to an approximate log-normal scale posterior qϕ(z)q_{\phi}(\mathbf{z}) in closed form (the derivation is given in Appendix D). More specifically, we have that the half-Cauchy prior can be expressed in a non-centered parametrization as:

where IG(⋅,⋅),G(⋅,⋅)\mathcal{IG}(\cdot,\cdot),\mathcal{G}(\cdot,\cdot) correspond to the inverse Gamma and Gamma distributions in the scale parametrization, and zz follows a half-Cauchy distribution with scale kk. Therefore we will re-express the whole hierarchy as:

to compute the final bit precision for the entire weight matrix W^\hat{\mathbf{W}}.

Experiments

We validated the compression and speed-up capabilities of our models on the well-known architectures of LeNet-300-100 , LeNet-5-Caffehttps://github.com/BVLC/caffe/tree/master/examples/mnist on MNIST and, similarly with , VGG The adapted CIFAR 10 version described at http://torch.ch/blog/2015/07/30/cifar.html. on CIFAR 10 . The groups of parameters were constructed by coupling the scale variables for each filter for the convolutional layers and for each input neuron for the fully connected layers. We provide the algorithms that describe the forward pass using local reparametrizations for fully connected and convolutional layers with each of the employed approximate posteriors at appendix F. For the horseshoe prior we set the scale τ0\tau_{0} of the global half-Cauchy prior to a reasonably small value, e.g. τ0=1e−5\tau_{0}=1e-5. This further increases the prior mass at zero, which is essential for sparse estimation and compression. We also found that constraining the standard deviations as described at and “warm-up" helps in avoiding bad local optima of the variational objective. Further details about the experimental setup can be found at Appendix A. Determining the threshold for pruning can be easily done with manual inspection as usually there are two well separated clusters (signal and noise). We provide a sample visualization at Appendix E.

We will first demonstrate the group sparsity capabilities of our methods by illustrating the learned architectures at Table 1, along with the inferred bit precision per layer. As we can observe, our methods infer significantly smaller architectures for the LeNet-300-100 and LeNet-5-Caffe, compared to Sparse Variational Dropout, Generalized Dropout and Group Lasso. Interestingly, we observe that for the VGG network almost all of big 512 feature map layers are drastically reduced to around 10 feature maps whereas the initial layers are mostly kept intact. Furthermore, all of the Bayesian methods considered require far fewer than the standard 32 bits per-layer to represent the weights, sometimes even allowing for 5 bit precisions.

2 Compression Rates

For the actual compression task we compare our method to current work in three different scenarios: (i) compression achieved only by pruning, here, for non-group methods we use the CSC format to store parameters; (ii) compression based on the former but with reduced bit precision per layer (only for the weights); and (iii) the maximum compression rate as proposed by .

We believe these to be relevant scenarios because (i) can be applied with already existing frameworks such as Tensorflow , (ii) is a practical scheme given upcoming GPUs and frameworks will be designed to work with low and mixed precision arithmetics . For (iii), we perform k-means clustering on the weights with k=32 and consequently store a weight index that points to a codebook of available weights. Note that the latter achieves highest compression rate but it is however fairly unpractical at test time since the original matrix needs to be restored for each layer. As we can observe at Table 2, our methods are competitive with the state-of-the art for LeNet-300-100 while offering significantly better compression rates on the LeNet-5-Caffe architecture, without any loss in accuracy. Do note that group sparsity and weight sparsity can be combined so as to further prune some weights when a particular group is not removed, thus we can potentially further boost compression performance at e.g. LeNet-300-100. For the VGG network we observe that training from a random initialization yielded consistently less accuracy (around 1%-2% less) compared to initializing the means of the approximate posterior from a pretrained network, similarly with , thus we only report the latter resultsWe also tried to finetune the same network with Sparse VD, but unfortunately it increased the error considerably (around 3% extra error), therefore we do not report those results.. After initialization we trained the VGG network regularly for 200 epochs using Adam with the default hyperparameters. We observe a small drop in accuracy for the final models when using the deterministic version of the network for prediction, but nevertheless averaging across multiple samples restores the original accuracy. Note, that in general we can maintain the original accuracy on VGG without sampling by simply finetuning with a small learning rate, as done at . This will still induce (less) sparsity but unfortunately it does not lead to good compression as the bit precision remains very high due to not appropriately increasing the marginal variances of the weights.

3 Speed and energy consumption

We demonstrate that our method is competitive with , denoted as GL, a method that explicitly prunes convolutional kernels to reduce compute time. We measure the time and energy consumption of one forward pass of a mini-batch with batch size 8192 through LeNet-5-Caffe. We average over 10410^{4} forward passes and all experiments were run with Tensorflow 1.0.1, cuda 8.0 and respective cuDNN. We apply 16 CPUs run in parallel (CPU) or a Titan X (GPU). Note that we only use the pruned architecture as lower bit precision would further increase the speed-up but is not implementable in any common framework. Further, all methods we compare to in the latter experiments would barely show an improvement at all since they do not learn to prune groups but only parameters. In figure 1 we present our results. As to be expected the largest effect on the speed up is caused by GPU usage. However, both our models and best competing models reach a speed up factor of around 8×\times. We can further save about 3 ×\times energy costs by applying our architecture instead of the original one on a GPU. For larger networks the speed-up is even higher: for the VGG experiments with batch size 256 we have a speed-up factor of 51×\times.

Conclusion

We introduced Bayesian compression, a way to tackle efficiency and compression in deep neural networks in a unified and principled way. Our proposed methods allow for theoretically principled compression of neural networks, improved energy efficiency with reduced computation while naturally learning the bit precisions for each weight. This serves as a strong argument in favor of Bayesian methods for neural networks, when we are concerned with compression and speed up.

We would like to thank Dmitry Molchanov, Dmitry Vetrov, Klamer Schutte and Dennis Koelma for valuable discussions and feedback. This research was supported by TNO, NWO and Google.

References

Appendix

We implemented our methods in Tensorflow and optimized the variational parameters using Adam with the default hyperparameters. The means of the conditional Gaussian qϕ(W∣z)q_{\phi}(\mathbf{W}|\mathbf{z}) were initialized with the scheme proposed at , whereas the log of the standard deviations were initialized by sampling from N(−9,1e−4)\mathcal{N}(-9,1e-4). The parameters of qϕ(z)q_{\phi}(\mathbf{z}) were initialized such that the overall mean of z\mathbf{z} is ≈1\approx 1 and the overall variance is very low (≈1e−8\approx 1e-8); this ensures that all of the groups are active during the initial training iterations.

As for the standard deviation constraints; for the LeNet-300-100 architecture we constrained the standard deviation of the first layer to be ≤0.2\leq 0.2 whereas for the LeNet-5-Caffe we constrained the standard deviation of the first layer to be ≤0.5\leq 0.5. The remaining standard deviations were left unconstrained. For the VGG network we constrained the standard deviations of the 64 and 128 feature map layers to be ≤0.1\leq 0.1, the standard deviations of the 256 feature map layers to be ≤0.2\leq 0.2 and left the rest of the standard deviations unconstrained. We also found beneficial the incorporation of “warm-up” , i.e we annealed the negative KL-divergence from the prior to the approximate posterior with a linear schedule for the first 100 epochs. We initialized the means of the approximate posterior by the weights and biases obtained from a VGG network trained with batch normalization and dropout on CIFAR 10. For our method we disabled batch-normalization during training.

As for preprocessing the data; for MNIST the only preprocessing we did was to rescale the digits to lie at the $$ range and for CIFAR 10 we used the preprocessed dataset provided by .

Furthermore, do note that by pruning a given filter at a particular convolutional layer we can also prune the parameters corresponding to that feature map for the next layer. This similarly holds for fully connected layers; if we drop a given input neuron then the weights corresponding to that node from the previous layer can also be pruned.

B. Standards for Floating-Point Arithmetic

Floating points values eventually need to be represented in a binary basis in a computer. The most common standard today is the IEEE 754-2008 convention . It defines xx-bit base-2 formats, officially referred to as binaryxx, with x∈{16,32,64,128}x\in\{16,32,64,128\}. The formats are also widely known as half, single, double and quadruple precision floats, respectively and used in almost all programming languages as a standard. The format considers 3 kinds of bits: one sign bit, ww exponent bits and pp precision bits.

The Sign bit determines the sign of the number to be represented. The exponent EE is an ww-bit signed integer, e.g. for single precision w=8w=8 and thus E∈E\in. In practice, exponents range from is smaller since the first and the last number are reserved for special numbers. The true significand or mantissa includes t bits on the right of the binary point. There is an implicit leading bit with value one. A values is consequently decomposed as follows

In table 3, we summarize common and less common floating point formats.

There is however the possibility to design a self defined format. There are 3 important quantities when choosing the right specification: overflow, underflow and unit round off also known as machine precision. Each one can be computed knowing the number of exponent and significant bits. in our work for example we consider a format that uses significantly less exponent bits since network parameters usually vary between . We set the unit round off equal to the precision and thus can compute the significant bits necessary to represent a specific weight.

Beyond designing a tailored floating point format for deep learning, recent work also explored the possibility of deep learning with mixed formats . For example, imagine the activations having high precision while weights can be low precision.

C. Shrinkage properties of the normal-Jeffreys and horseshoe priors

In this section we will provide some insights about the behavior of each of the priors we employ by following the excellent analysis of ; we can perform a change of variables and express the scale mixture distribution of eq.3 in the main paper in terms of a shrinkage coefficient, λ=11+z2\lambda=\frac{1}{1+z^{2}}:

It is easy to observe that eq. 23 corresponds to a continuous relaxation of the spike-and-slab prior: when λ=0\lambda=0 we have that p(w∣λ=0)=U(−∞,∞)p(w|\lambda=0)=\mathcal{U}(-\infty,\infty), i.e. no shrinkage/regularization for ww, when λ=1\lambda=1 we have that p(w∣λ=1)=δ(w=0)p(w|\lambda=1)=\delta(w=0), i.e. ww is exactly zero, and when λ=12\lambda=\frac{1}{2} we have that p(w∣λ=12)=N(0,1)p(w|\lambda=\frac{1}{2})=\mathcal{N}(0,1). Now by examining the implied prior on the shrinkage coefficient λ\lambda for both the log-uniform and the horseshoe priors we can better study their behavior. As it is explained at , the half-Cauchy prior on zz corresponds to a beta prior on the shrinkage coefficient, p(λ)=B(12,12)p(\lambda)=\mathcal{B}(\frac{1}{2},\frac{1}{2}), whereas the normal-Jeffreys / log-uniform prior on zz corresponds to p(λ)=B(ϵ,ϵ)p(\lambda)=\mathcal{B}(\epsilon,\epsilon) with ϵ≈0\epsilon\approx 0. The densities of both of these distributions can be seen at Figure 3(b). As we can observe, the log-uniform prior posits a distribution that concentrates almost all of its mass at either λ≈0\lambda\approx 0 or λ≈1\lambda\approx 1, essentially either pruning the parameter or keeping it close to the maximum likelihood estimate due to p(w∣λ≈1)=U(−∞,∞)p(w|\lambda\approx 1)=\mathcal{U}(-\infty,\infty). In contrast the horseshoe prior maintains enough probability mass for the in-between values of λ\lambda and thus can, potentially, offer better regularization and generalization.

D. Negative KL-divergences for log-normal approximating posteriors

Let q(z)=LN(μ,σ2)q(z)=\mathcal{LN}(\mu,\sigma^{2}) be a log-normal approximating posterior. Here we will derive the negative KL-divergences to q(z)q(z) from inverse gamma, gamma and half-normal distributions.

Let p(z)p(z) be an inverse gamma distribution, i.e. p(z)=IG(α,β)p(z)=\mathcal{IG}(\alpha,\beta). The negative KL-divergence can be expressed as follows:

The second term is the entropy of the log-normal distribution which has the following form:

The first term is the negative cross-entropy of the log-normal approximate posterior from the inverse-Gamma prior:

Now let p(z)p(z) be a Gamma prior, i.e. p(z)=G(α,β)p(z)=\mathcal{G}(\alpha,\beta). We have that the negative cross-entropy changes to:

E. Visualizations

F. Algorithms for the feedforward pass

Algorithms 1, 2, 3, 4 describe the forward pass using local reparametrizations for fully connected and convolutional layers with the approximate posteriors for the Bayesian Compression (BC) with group normal-Jeffreys (BC-GNJ) and group Horseshoe (BC-GHS) priors employed at the experiments. For the fully connected layers we coupled the scales for each input neuron whereas for the convolutional we couple the scales for each output feature map. Mw,Σw\mathbf{M}_{w},\boldsymbol{\Sigma}_{w} are the means and variances of each layer, H\mathbf{H} is a minibatch of activations of size KK. For the first layer we have that H=X\mathbf{H}=\mathbf{X} where X\mathbf{X} is the minibatch of inputs. For the convolutional layers NfN_{f} are the number of convolutional filters, ∗* is the convolution operator and we assume the [batch, height, width, feature maps] convention.