B ALANCING TRAINING TIME VS . PERFORMANCE WITH B AYESIAN E ARLY P RUNING
Anonymous authors
Paper under double-blind review
A BSTRACT
Pruning is an approach to alleviate overparameterization of deep neural network (DNN) by zeroing out or pruning DNN elements with little to no efﬁcacy at a given task.
In contrast to related works that do pruning before or after training, this paper presents a novel method to perform early pruning of DNN elements (e g., neurons or convolutional ﬁlters) during the training process while preserving performance upon convergence.
To achieve this, we model the future efﬁcacy of DNN elements in a Bayesian manner conditioned upon efﬁcacy data collected during the training and prune DNN elements which are predicted to have low efﬁcacy after training completion.
Empirical evaluations show that the proposed Bayesian early pruning improves the computational efﬁciency of DNN training.
Using our approach we are able to achieve a 48 .
6% faster training time for ResNet- 50 on ImageNet to achieve a validation accuracy of 72 . 5% .
I NTRODUCTION
Deep neural networks (DNNs) are known to be overparameterized (Allen-Zhu et al., 2019) as they usually have more learnable parameters than needed for a given learning task.
So, a trained DNN contains many ineffectual parameters that can be safely pruned or zeroed out with little/no effect on its predictive accuracy.
Pruning (LeCun et al., 1989) is an approach to alleviating overparameterization of a DNN by identifying and removing its ineffectual parameters while preserving its predictive accuracy on the validation/test dataset.
Pruning is typically applied to the DNN after training to speed up testing-time evaluation .
For standard image classiﬁcation tasks with MNIST, CIFAR- 10 , and ImageNet datasets, it can reduce the number of learnable parameters by up to 50% or more while maintaining test accuracy (Han et al., 2015; Li et al., 2017; Molchanov et al., 2017).
In particular, the overparameterization of a DNN also leads to considerable training time being wasted on those DNN elements (e.g., connection weights, neurons, or convolutional ﬁlters) which are eventually ineffectual after training and can thus be safely pruned.
Our work in this paper considers early pruning of such DNN elements by identifying and removing them throughout the training process instead of after training.
1 As a result, this can signiﬁcantly reduce the time incurred by the training process without compromising the ﬁnal test accuracy (upon convergence) much.
Recent work (Section 5) in foresight pruning (Lee et al., 2019; Wang et al., 2020) show that pruning heuristics applied at initialization work well to prune connection weights without signiﬁcantly degrading performance.
In contrast to these work, we prune throughout the training procedure, which improves performance after convergence of DNNs, albeit with somewhat longer training times.
In this work, we pose early pruning as a constrained optimization problem (Section 3.1).
A key challenge in the optimization is accurately modeling the future efﬁcacy of DNN elements.
We achieve this through the use of multi-output Gaussian process which models the belief of future efﬁcacy conditioned upon efﬁcacy measurements collected during training (Section 3.2).
Although the posed optimization problem is NP-hard, we derive an efﬁcient Bayesian early pruning (BEP) approximation algorithm, which appropriately balances the inherent training time vs. performance tradeoff in pruning prior to convergence (Section 3.3).
Our algorithm relies on a measure of network element efﬁcacy, termed saliency (LeCun et al., 1989).
The development of saliency functions is an active area of research with no clear optimal choice.
To accomodate this, our algorithm is agnostic, and therefore ﬂexible, to changes in saliency function.
We use BEP to prune neurons and convolutional ﬁlters to achieve practical speedup during training (Section 4).
Our approach also compares favorably to state-of-the-art works such as SNIP (Lee et al., 2019), GraSP (Wang et al., 2020), and momentum based dynamic sparse reparameterization (Dettmers & Zettlemoyer, 2019).
P RUNING
Consider a dataset of D training examples X
= { x 1 , . . .
, x D } , Y = { y 1 , . . .
, y D } and a neural network N v t parameterized by a vector of M pruneable network elements (e.g. weight parameters, neurons, or convolutional ﬁlters) v t (cid:44) [ v at ] a =1 ,...,M , where v t represent the network elements after t iterations of stochastic gradient descent (SGD) for t = 1 , . . .
, T .
Let L ( X , Y ; N v t ) be the loss function for the neural network N v t .
Pruning aims at reﬁning the network elements v t given some sparsity budget B and preserving the accuracy of the neural network after convergence (i.e., N v T ), which can be stated as a constrained optimization problem (Molchanov et al., 2017):
[Equation]
where (cid:12) is the Hadamard product and m is a pruning mask.
Note that we abuse the Hadamard product for notation simplicity: for a = 1 , .., M , m a × v aT corresponds to pruning v aT if m a = 0 , and keeping v aT otherwise.
Pruning a network element refers to zeroing the network element or the weight parameters which compute the network element.
Any weight parameters which reference the output of the pruned network element are also zeroed since the element outputs a constant 0 .
The above optimization problem is difﬁcult due to the NP-hardness of combinatorial optimization.
This leads to the approach of using saliency function s which measures efﬁcacy of network elements at minimizing the loss function.
A network element with small saliency can be pruned since it’s not salient in minimizing the loss function.
Consequently, pruning can be done by maximizing the saliency of the network elements given the sparsity budget B :
[Equation]
where s ( a ; X , Y , N v T , L ) measures the saliency of v aT at minimizing L after convergence through
T iterations of SGD.
The above optimization problem can be efﬁcienctly solved by selecting the B most salient network elements in v T .
The construction of the saliency function has been discussed in many existing works: Some approaches derived the saliency function from ﬁrst-order (LeCun et al., 1989;
Molchanov et al., 2017) and second-order (Hassibi & Stork, 1992; Wang et al., 2020)
Taylor series approximations of L .
Other common saliency functions include L 1 (Li et al., 2017) or L 2 (Wen et al., 2016) norm of the network element weights, as well as mean activation (Polyak & Wolf, 2015).
In this work, we use a ﬁrst-order Taylor series approximation saliency function deﬁned for neurons and convolutional ﬁlters
(Molchanov et al., 2017), however our approach remains ﬂexible to arbitrary choice of saliency function on a plug-n-play basis.
B AYESIAN E ARLY P RUNING 3. P ROBLEM STATEMENT
As has been mentioned before, existing pruning works based on the saliency function are typically done after the training convergence (i.e., (2)) to speed up the testing-time evaluation, which waste considerable time on training these network elements which will eventually be pruned.
To resolve this issue, We extend the pruning problem deﬁnition (2) along the temporal dimension, allowing network elements to be pruned during the training process consisting of T iterations of SGD.
Let s at (cid:44) s ( a ; X , Y , N v t , L ) be a random variable which denotes the saliency of network element v at after t iterations of SGD, s t (cid:44) [ s at ] a =1 ,...,M for t = 1 , . .
, T , and s τ 1 : τ 2 (cid:44) [ s t ] t
=
τ 1 ,...,τ 2 be a vector of saliency of all the network elements between iterations τ 1 and τ 2 .
Our early pruning algorithm is designed with the goal of maximizing the saliency of the unpruned elements after iteration T , yet allowing for pruning at each iteration t given some computational budget B t,c for t = 1 , . . .
, T :
[Equation]
where B s is the trained network sparsity budget, ˜ s 1: t is a vector of observed values for s 1: t , mis an M -dimensional 1 ’s vector, and m t ˙
≤ m t − 1 represents an element-wise comparison between m t and m t − 1 : m at ≤ m at − 1 for a = 1 , . .
, M .
At each iteration t , the saliency s t is observed and m t ∈ { 0 , 1 } M in ρ t represents a pruning decision performed to maximize the expectectation of ρ t + conditioned upon saliency measurements s 1: t collected up to and including iteration t .
This recursive structure terminates with base case
ρ T where the saliency of the unpruned elements is maximized after T iterations of training.
In the above early pruning formulation 4 , constraints (3c) and (4b) ensure pruning is performed in a practical manner whereby once a network element is pruned, it can no longer be recovered in a later training iteration.
We deﬁne a trained network sparsity budget, B s (3b), which may differ signiﬁcantly from initial network size || m 0 ||
(e.g., in the case where the network is trained on GPUs, but deployed on resource constrained edge or mobile devices).
We also constrain a total computational effort budget B t,c which is reduced per training iteration t by the number of unpruned network elements || m t || 0 .
We constrain B T,c ≥ 0 (3d) to ensure training completion within the speciﬁed computational budget.
Here we assume that a more sparse pruning mask m t corresponds to lower computational effort during training iteration t due to updating fewer network elements.
Finally, (3a) maximizes the saliency with a pruning mask m T constrained by a sparsity budget B s (3b).
Our early pruning formulation balances the saliency of network elements after convergence against the total computational effort to train such network (i.e., m T · s T vs. (cid:80)
Tt =
1 || m t || 0 ).
This appropriately captures the balancing act of training-time early pruning whereby the computational effort is saved by early pruning network elements while preserving the saliency of the remaining network elements after convergence.
3. M ODELING THE S ALIENCY WITH M ULTI -O UTPUT G AUSSIAN P ROCESS
To solve the above early pruning problem, we need to model the belief p ( s 1: T ) of the saliency for computing the predictive belief p ( s t +1: T | ˜ s 1: t ) of the future saliency in (4a).
At the ﬁrst glance, one may consider to decompose the belief: p ( s 1: T ) (cid:44) (cid:81) Ma =1 p ( s a 1: T ) and model the saliency s a 1: T (cid:44) [ s a t ] t =1 ,...,T of each network element independently.
Such independent models, however, ignore the co-adaptation and co-evolution of the network elements which have been shown to be a common occurrence in DNN (Hinton et al., 2012;
Srivastava et al., 2014; Wang et al., 2020).
Also, modeling the correlations between the saliency of different network elements explicitly is non-trivial since considerable feature engineering is needed for representing diverse network elements such as neurons, connections, or convolutional ﬁlters.
To resolve such issues, we use multi-output Gaussian process (MOGP) to jointly model the belief p ( s 1: T ) of all saliency measurements.
To be speciﬁc, we assume that the saliency s at of the a -th network element at iteration t is a linear mixture 5 of Q independent latent functions { u q ( t ) } Qq =1 : s at (cid:44) (cid:80) Qq {+=
+}
γ aq u q ( t ) .
As shown in ( ´Alvarez & Lawrence, 2011), if each u q ( t ) is an independent
GP with prior zero mean and covariance k q ( t, t (cid:48) ) , then the resulting distribution over p ( s 1: T ) is a multivariate Gaussian distribution with prior zero mean and covariance determined by the mixing weights: cov
[ s at , s a (cid:48) t (cid:48) ]
= (cid:80) Qq =1 γ aq γ a (cid:48)
q k q ( t, t (cid:48) ) .
This explicit covariance between s at and s a (cid:48) t (cid:48) helps to exploit the co-evolution and co-adaptation of network elements within the neural networks.
To capture the horizontal asymptote trend of s a 1 , . .
, s aT as visualized in Appendix A.2, we turn to a kernel used for modeling decaying exponential curves known as the “exponential kernel” (Swersky et al., 2014) and set k q ( t, t (cid:48) )
(cid:44) β qαq ( t + t (cid:48) + β q ) αq where α q and β q are hyperparameters of MOGP and can be learned via maximum likelihood estimation ( ´Alvarez & Lawrence, 2011).
Then, given a vector of observed saliency ˜ s 1: t , the MOGP regression model can provide a Gaussian predictive distribution for any future saliency s t (cid:48) .
Thus, the predictive mean µ at (cid:48) | 1: t (cid:44) E [ s at (cid:48) | ˜ s 1: t ] of the saliency s at (cid:48) and the predictive (co)variance σ aa (cid:48) t (cid:48) | 1: t (cid:44) cov
[ s at (cid:48) , s a (cid:48) t (cid:48)
| ˜ s 1: t ] between the saliency s at (cid:48) and s a (cid:48) t (cid:48) can be computed analytically, as detailed in Appendix A.3.
3. E ARLY PRUNING ALGORITHM
Solving the above optimizing problem (3) and (4) is difﬁcult due to the interplay between [ m
[Equation]
,c ] t [Equation]
= t,...,T , and m T · s T .
Instead, we consider a simpliﬁcation of the above problem by only considering solutions of the form m T − 1 = m T −
= . . .
= m t which yields 6 :
[Equation]
This approach allows us to lift (3d) from (3), to which we add a Lagrange multiplier and achieve:
[Equation]
for t = 1 , . . .
, T − 1 and ˆ ρ T is deﬁned as ρ T without constraint (3d).
Consequently, such a ˆ ρ T can be solved in a greedy manner as in (2).
Afterwards, we will omit B t,c as a parameter of ˆ ρ T as it no longer constrains the solution of ˆ ρ T .
Note that the presence of an additive penalty in a maximization problem is due to the constraint B T,c ≥ 0 ⇔ − B T,c ≤ 0 which is typically expected prior to Lagrangian reformulation.
The above optimization problem remains NP-hard as E p ( s T | ˜ s 1: t ) [ˆ ρ T ( m t , B s )] is submodular in m t (see Appendix B).
Although greedy approximations exist for submodular optimization, their running time of O ( || m t − 1 || 20 ) remains far too slow due to the large number of network elements in DNNs.
Fortunately, it can be signiﬁcantly simpliﬁed by exploiting the following lemma (its proof is in Appendix C.):
Lemma 1.
Let e ( i ) be an M -dimensional one-hot vectors with the i -th element be 1 .
∀ 1 ≤ a, b ≤ M ; m ∈ { 0 , 1 } M s.t.
m
∧ ( e ( a ) ∨ e ( b ) ) = 0 .
Given a vector of observed saliency ˜ s 1: t , if µ aT | 1: t ≥ µ bT | 1: t and µ aT | 1: t ≥ 0 , then
[Equation]
where θ (cid:44) (cid:113) σ aaT | 1: t + σ bbT | 1: t − 2 σ abT | 1: t , ν (cid:44) µ bT | 1: t − µ aT | 1: t , and Φ and φ are standard normal
CDF and PDF, respectively.
Here, ‘ ∨ ’ and ‘ ∧ ’ represent bitwise OR and AND operations, respectively.
The bitwise OR operation is used to denote the inclusion of e ( a ) or e ( b ) in m t .
Due to the strong tail decay 7 of φ and Φ ,
Lemma 1 indicates at most marginal possible improvement provided by opting for m t
= m ∨ e ( b ) as opposed to m t = m ∨ e ( a ) given µ aT | 1: t ≥ µ bT | 1: t .
Lemma 1 admits the following approach to optimize ˆ ρ t : starting with m t =
M , we consider the inclusion of network elements in m t by the descending order of { µ aT | 1: t } Ma =1 which can be computed analytically using MOGP.
A network element denoted by e ( a ) is included in m t if it improves the objective in (5).
The algorithm terminates once the highest not-yet-included element does not improve the objective function as a consequence of the penalty term outweighing the improvement in E p ( s T | ˜ s 1: t ) [ ρ T ] .
The remaining excluded elements are then pruned.
Following the algorithm sketch above, we deﬁne the utility of network element v at with respect to candidate pruning mask m t ˙ ≤ m t − 1 which measures the improvement in E p ( s T | ˜ s 1: t ) [ ρ T ] as a consequence of inclusion of e ( a ) in m t :
[Equation]
We can now take a Lagrangian approach to pruning decisions during iteration t by balancing the utility of network element v at against the change of the penalty (i.e., λ ( T − t ) ) in Algorithm 1.
Due to the relatively expensive cost of performing early pruning, we chose to early prune every T step iterations of SGD.
Typically T step was chosen to correspond to 10 - 20 epochs of training.
To compute ∆( · ) we sampled from p ( s T | ˜ s 1: t ) and used a greedy selection algorithm per sample as in (2).
During implementation, we also enforced an additional hard constraint
|| m t || 0 ≥ B s which we believe is desirable for practicality reasons.
We used a ﬁxed value of B 1 ,c
= || m
|| 0 T 0 + B s ( T − T 0 ) in all our experiments.
Algorithm
Require: N , v 1 , T 0 , T step , T , B 1 ,c , B s , λ (cid:46) DNN N , Lagrangian penalty λ 1: S 1: T 0 ← train ( N v 1 , T 0 )
(cid:46) Train for T 0 iterations to create seed dataset.
2: B T 0 ,c ← B 1 ,c − T 0 dim ( v 1 ) (cid:46) Track computational effort expenditure.
3: for k ← 0 , . . .
, T − T 0 T step ; t ← T 0 + kT step do (cid:46)
Early prune every T step iterations from T 0 .
4: µ T | 1: t , σ T | 1: t ← MOGP ( S 1: t ) (cid:46) Train and perform inference.
5: s T ← argsort ( − µ T | 1: t ) (cid:46) Sort descending.
6: m t ← 0 dim ( v t ) (cid:46)
Initial pruning mask.
7: for a ← s 1 T , . . .
, s dim ( v t ) T do (cid:46) Consider each network element.
8: if B t,c − ( T − t ) || m t || 0 > 0 then (cid:46)
Remaining B t,c budget can support training v at .
9: m t = m t ∨ e ( a ) 10: else if ∆( a, m t , ˜ s 1: t , B s ) ≥ λ ( T − t ) then (cid:46) Balance utility against change of penalty.
11: m t = m t ∨ e ( a ) 12: else 13: break 14: prune ( v t , m t ) (cid:46) dim ( v t ) is reduced here.
B t + T step ,c ← B t,c − T step || m t ||16:
S t +1:
t + T step ← train ( N v t , T step ) (cid:46) Continue training with pruned network.
17: return N
E XPERIMENTS AND D ISCUSSION
We evaluate our modeling approach as well as our BEP algorithm on the CIFAR- 10 , CIFAR100 (Krizhevsky, 2009), and ImageNet (Deng et al., 2009) datasets.
For CIFAR- 10 /CIFAR- 100 we used a benchmark Convolutional Neural Network (CNN) with 4 convolutional layers, and 1 dense layer.
For ImageNet we validated on the ResNet-50 architecture (He et al., 2016a).
Due to the cubic time complexity of MOGPs, we used a variational approximation (Hensman et al., 2015).
In all of our models, we used 60 variational inducing points per latent function.
We used
GPFlow library (Matthews et al., 2017) to build our models.
4. M ODELING EVALUATION
A key assertion in our approach is the importance of capturing co-adaptation and co-evolution effects in network elements.
To verify our MOGP approach captures these effects, we compare MOGP vs. GP belief modeling where GP assumes independence in saliency measurements across network elements (i.e., p ( s 1: T ) (cid:44) (cid:81)
Ma =1 p ( s a 1: T ) ).
A dataset of saliency measurements of convolutional ﬁlters and neurons was constructed by instrumenting the training process of our 5-layer CNN on the CIFAR- 10 /CIFAR- 100 dataset.
Keras (Chollet, 2015) was used to train this model over 150 epochs.
[Figure] [Figure]
[Table]
We trained belief models with small ( t = [0 , 26] epochs), medium ( t = [0 , 40] epochs), and large ( t = [0 , 75] epochs) training dataset of saliency measurements.
For GPs, a separate model was trained per network element (convolutional ﬁlter, or neuron).
For MOGP, all network elements in a single layer 10 shared one MOGP model.
We evaluated these models using log likelihood of the remainder of the saliency measurements.
We present the performance of the models in Table 1 for
CIFAR- 100 .
Our MOGP approach better captures the saliency of network elements than a GP approach.
Furthermore, using additional latent functions improves MOGP modeling with diminishing returns.
We visualize the qualitative differences between GP and MOGP prediction in Figure 1.
We observe that MOGP is able to capture the long term trend of saliency curves with signiﬁcantly less data than GP.
4. S MALL - SCALE EXPERIMENTS
We applied the early pruning algorithm on the aforementioned architecture, and training regimen.
We investigated the behavior of the penalty parameter, λ .
We observed that the penalty parameter was difﬁcult to tune properly, either being too aggressive at pruning, or too passive.
To rectify this issue, we used a feedback loop to determine the penalty at iteration t , λ t dynamically.
Dynamic penalty scaling 12 uses feedback from earlier pruning iterations to increase or decrease the iteration penalty at time t: λ t = λ
[(1 /λ ) ∧ (( T − t )
|| m t || 0 /B
t,c − 1)] .
The dynamic penalty is increased if the anticipated compute required to complete training, ( T − t )
|| m t
|| 0 begins to exceed the amount of compute budget remaining, B t,c .
In such case, a higher penalty is needed to satisfy the computational budget constraint as per (6).
We compare dynamic penalty scaling, and penalty without scaling in
Fig.
2 using T 0 = 20 epochs, T step = 10 epochs for the ﬁrst convolutional layer of our CNN.
Going forward, we use dynamic penalty scaling in our experiments.
[Figure] [Table] We compare our work with SNIP (Lee et al., 2019), GraSP (Wang et al., 2020), and momentum-based dynamic sparse remaparameterization (DSR) (Dettmers & Zettlemoyer, 2019).
To compare against
DSR, we instantiate a smaller network of the size BEP yields after training has completed as it is a prune and regrow method.
The SNIP and GraSP approaches are extended to neurons/ﬁlters by averaging the saliencies of the constituent weight parameters.
We experimented with various degrees of sparsity, using BEP to prune a portion of ﬁlters/neurons of each layer.
13 We present the results in
Table 2.
Our approach better preserves performance at equivalent sparsity.
A lower penalty yields higher performing results showing λ serves well at balancing performance vs. computational budget.
We investigate the robustness of BEP and MOGP hyperparameters.
We vary the number of MOGP variational inducing points, MOGP latent functions, and T step and observe the performance of BEP 1e − 4 on CIFAR- 10 /CIFAR- 100 at 80% , 90% , and 95% sparsity.
We present these results in Table 3.
We observe that in general, all hyperparameters are robust to changes. Mild degradation is observed in the extremal hyperparameter settings.
4. S PEEDING UP R ES N ET TRAINING ON I MAGE N ET
Our chief goal in this work is to speed up training of large-scale DNNs such as ResNet (He et al., 2016a;b) on the ImageNet dataset.
Pruning ResNet requires a careful deﬁnition of network element saliency to allow pruning of all layers.
ResNet contains long sequences of residual units with matching number of input/output channels.
The inputs of residual units are connected with shortcut connections (i.e., through addition) to the output of the residual unit.
14 Due to shortcut connections, this structure requires that within a sequence of residual units, the number of inputs/output channels of all residual units must match exactly.
This requires group pruning of residual unit channels for
[Table]
a sequence of residual units, where group pruning an output channel of a residual unit sequence requires pruning it from the inputs/outputs of all residual units within the sequence.
We trained ResNet- 50 with BEP as well as SNIP and GraSP.
16 We group pruned less aggressively as residual unit channels feed into a large number of residual units, thus making aggressive pruning likely to degrade performance.
We ran BEP iterations at t =
[15 , 20 , 25 , 35 , 45 , 55 , 75] epochs.
We trained for 100 epochs on 4 × Nvidia Geforce GTX 1080 Ti GPUs.
More experimental details found in Appendix G.2.
We present our results in Table 4.
We achieve higher performance than related techniques, albeit at longer wall time.
Our approach captures the training time vs. performance tradeoff present in DNNs, unlike competing approaches.
R ELATED W ORK
Pruning and related techniques.
Initial works in DNN pruning center around saliency based pruning after training including Skeletonization (Mozer & Smolensky, 1988), Optimal Brain Damage and followup work (Hassibi & Stork, 1992; LeCun et al., 1989) as well as sensitivity based pruning (Karnin, 1990).
In recent years, saliency functions been adapted to pruning neurons or convolutional ﬁlters.
Li et al.
(2017) deﬁne a saliency function on convolutional ﬁlters by using the
L 1 norm.
Molchanov et al.
(2017) propose using a ﬁrst-order Taylor-series approximation on the objective function as a saliency measure.
Dong et al.
(2017) propose layer wise pruning of weight parameters using a Hessian based saliency measure.
Several variants of pruning after training exist.
Han et al.
(2015) propose iterative pruning where pruning is performed in stages alternating with ﬁne tune training.
Guo et al.
(2016) suggest dynamic network surgery, where pruning is performed on-the-ﬂy during evaluation time.
Li et al.
(2017) and He et al.
propose reinforcement learning for pruning decisions.
A comprehensive overview may be found in Gale et al.
Knowledge distillation (Hinton et al., 2015; Lu et al., 2017; Tung & Mori, 2019; Yim et al., 2017) aim to transfer the capabilities of a trained network into a smaller network.
Weight sharing (Nowlan &
Hinton, 1992; Ullrich et al., 2017) and low rank matrix factorization (Denton et al., 2014; Jaderberg et al., 2014) aim to compress the parameterization of neural networks.
Network quantization (Courbariaux et al., 2015; Hubara et al., 2017; Micikevicius et al., 2018) use lower ﬁdelity representation of network elements (e.g. 16-bit) to speed up training and evaluation.
Although speedup during training is achievable through network quantization, this technique requires hardware support and only [Table] provides coarse granularity in trading off computational effort vs. performance.
Current GPUs only extend native support to 16-bit ﬂoating point operations.
Furthermore, our approach is orthogonal to quantization allowing the techniques to be combined for further speedup.
Initialization time or training time pruning.
Frankle & Carbin (2019) show that a randomly initialized DNN contains a small subnetwork, which if trained by itself, yields equivalent performance to the original network.
SNIP (Lee et al., 2019) and GraSP (Wang et al., 2020) propose pruning connection weights prior to the training process through a ﬁrst order and second order saliency function respectively.
Sparse Evolutionary Training (Mocanu et al., 2018) propose initializing networks with sparse topology prior to training.
Narang et al.
(2017) consider connection weight pruning during training for recurrent neural networks using a heuristic approach.
Dynamic sparse reparameterization considers pruning and regrowing parameter weights during the training process (Bellec et al., 2018; Dettmers & Zettlemoyer, 2019; Mostafa & Wang, 2019).
Dai et al.
(2019) propose a grow and prune approach to learning network architecture and connection layout.
We differ from existing work as our focus is on speeding up neural network training, meanwhile other works in training time pruning aim to achieve sparse network layouts.
To the best of our knowledge, except for small speedups presented in (Dettmers & Zettlemoyer, 2019), the above works do not demonstrate speedup during training time using popular deep learning libraries run on modern GPUs.
PruneTrain (Lym et al., 2019) also proposes pruning ﬁlters during training to achieve speedup with periodic pruning iterations.
In contrast to our approach, PruneTrain does not allow speciﬁcation of the desired network size after training.
A speciﬁed network size may be useful if training for resource constrained devices such as mobile phones or edge devices.
We compare with PruneTrain under the early pruning problem deﬁnition in Appendix E.
C ONCLUSION
This paper presents a novel efﬁcient algorithm to perform pruning of DNN elements such as neurons, or convolutional layers during the training process.
To achieve early pruning before the training converges while preserving the performance of the DNN upon convergence, a Bayesian model (i.e., MOGP) is used to predict the saliency of DNN elements in the future (unseen) training iterations by exploiting the exponentially decaying behavior of the saliency and the correlations between saliency of different network elements.
Then, we exploit a property (Lemma 1) of the objective function and propose an efﬁcient Bayesian early pruning algorithm.
Empirical evaluations on benchmark datasets show that our algorithm performs favorably to related works for pruning convolutional ﬁlters and neurons.
Our approach remains ﬂexible to changes in saliency function, and appropriately balances the training time vs. performance tradeoff in training DNNs.
We are able to train an early pruned ResNet- 50 model achieving a 48 .
6% speedup ( 37 h vs. 55 h) while maintaining a validation accuracy of 72 . 5% .
A M ODELING DETAILS A. S ALIENCY FUNCTION
In this work, we use a ﬁrst order Taylor-series saliency function proposed by Molchanov et al.
Our design (Section 3) remains ﬂexible to allow usage of arbitrary saliency functions in a plug-n-play basis.
We partition a DNN of L layers, where each layer (cid:96) contains C (cid:96) convolutional ﬁlters, into a sequence of convolutional ﬁlters [ z (cid:96),c ] c =1 ,...,C (cid:96) (cid:96) =1 ,...,L .
Each ﬁlter z (cid:96),c : R C (cid:96)
[Figure]
1 × W (cid:96)
[Figure]
H (cid:96)
[Figure]
1 → R W (cid:96) × H (cid:96) can be considered as one network element in v T and z (cid:96),c ( P (cid:96) − 1 ) (cid:44) R ( W (cid:96),c ∗ P (cid:96) − 1 + b (cid:96),c ) where
W (cid:96),c ∈ R C (cid:96) × O (cid:96) × O (cid:48) (cid:96) , b (cid:96),c are kernel weights and bias.with receptive ﬁeld O (cid:96) × O (cid:48) (cid:96) , ‘ ∗ ’ represents the convolution operation, R is the activation function, P (cid:96) − 1 represents the output of z (cid:96) − 1 (cid:44)
[ z (cid:96) − 1 ,c (cid:48) ]
c (cid:48)
=1 ,...,C (cid:96) − 1 with P 0 corresponding to an input x d ∈ X , and W (cid:96) , H (cid:96) are width and height dimensions of layer (cid:96) for (cid:96) = 1 , . . .
, L .
Let N z (cid:96) :
z (cid:96) (cid:48) (cid:44) z (cid:96) (cid:48) ◦ , . . .
, ◦ z (cid:96) denote a partial neural network of layers [ (cid:96), . . .
, (cid:96) (cid:48) ] 1 ≤ (cid:96) ≤ (cid:96) (cid:48) ≤ L .
The Taylor-series saliency function on the convolutional ﬁlter z (cid:96),c denoted as s ([ (cid:96), c ]) is deﬁned 17 :
[Equation]
(8) where P ( x d ) (cid:96) is the output of the partial neural network N z 1 : z (cid:96) with x d as the input and [ P x d (cid:96),c,j ] j =1 ,...,W (cid:96) × H (cid:96) interprets the output of the c -th ﬁlter in vectorized form.
This function uses the ﬁrst-order Taylor-series approximation of L to approximate the change in loss if z (cid:96),c was changed to a constant 0 function.
Using the above saliency deﬁnition, pruning ﬁlter z (cid:96),c corresponds to collectively zeroing W (cid:96),c , b (cid:96),c as well as weight parameters 18 [ W (cid:96) +1 ,c (cid:48) , { : , : ,c } ] c (cid:48)
=1 ,...,C (cid:96) +1 of z (cid:96) +1 which utilize the output of z l,c .
This deﬁnition can be extended to elements (e.g. neurons) which output scalars by setting W (cid:96) =
H (cid:96) = 1 .
A. O N THE CHOICE OF THE “ EXPONENTIAL KERNEL ”
We justify our choice of the exponential kernel as a modeling mechanism by presenting visualizations of saliency measurements collected during training, and comparing these to samples drawn from the exponential kernel k q ( t, t (cid:48) )
(cid:44) β
α
( t + t (cid:48)
+ β ) α , as shown in Figs.
Both the saliency and the function samples exhibit exponentially decaying behavior, which makes the exponential kernel a strong ﬁt for modeling saliency evolution over time.
Furthermore we note that the exponential kernel was used to great effect in Swersky et al.
with respect to modeling loss curves as a function of epochs.
Loss curves also exhibit asymptotic behavior, similar to saliency measurement curves, thus providing evidence for the exponential kernel being an apt ﬁt for our task.
A. P REDICTIVE DISTRIBUTION OF THE SALIENCY
Let the prior covariance matrix be K τ 1 : τ 2 (cid:44)
[Equation]
for any 1 ≤ τ 1 ≤ τ 2 ≤ T .
Given a vector of observed saliency , the MOGP regression model can provide a Gaus-
[Figure] [Figure]
(a
[Figure]
α
[Figure]
β
[Figure] [Figure]
0 20 40 60 80 100 120 140 x −
[Figure]
−0.
[Figure]
−0.
[Figure] [Figure]
[Figure] [Figure]
[Figure]
f ( x ) (b) α = β
= 1 .0 20
[Figure]
120 140 x −1.
−0.
[Figure]
f ( x ) (c) α = β = 1 .
sian predictive distribution p (
[Equation]
= N
[Equation]
K
[Equation]
1: t ) for any future saliency s t (cid:48) with the following posterior mean vector and covariance matrix: µ
[Equation] [Equation]
(cid:48) t ]
[Equation] [Equation]
[Equation] [Equation]
(cid:48)
[Equation] [Equation]
K
[Equation]
(cid:48)
[Equation]
− K [
[Equation]
(cid:48)
[Equation]
] K −
[Equation]
1: t K (cid:62) [ t (cid:48) t ] where K [ t (cid:48) t ] (cid:44) [ cov [ s at (cid:48) , s a (cid:48)
[Equation]
]] a,
[Equation]
(cid:48)
=1 ,...,M τ =1 ,...,t .
Then, the a -th element µ at (cid:48) | 1: t of µ t (cid:48)
| 1: t is the predictive mean of the saliency s at (cid:48) .
And the [ a, a (cid:48) ] -th element of K [ t (cid:48)
t ] denoted as σ aa (cid:48)
t the predictive (co)variance between the saliency s at (cid:48) and s a (cid:48)
B S UBMODULARITY OF E [ˆ ρ T ]
In (6), the problem of choosing m from { 0 , 1 } M can be considered as selecting a subset A of indexes from { 1 , . . .
, M } such that m at = 1 for a ∈ A , and m at =
otherwise.
Therefore,
P ( m ) (cid:44) E p ( s T | ˜ s 1: t )
[ˆ ρ T ( m , B s )] can be considered as a set function which we will show to be submodular.
To keep notation consistency, we will remain using P ( m ) instead of representing it as a function of the index subset A .
Lemma 2 ( Submodularity ) .
Let m (cid:48) , m (cid:48)(cid:48) ∈ { 0 , 1 } M , and e ( a ) be arbitrary M-dimensional one hot vector with 1 ≤ a ≤ M .
We have P ( m (cid:48) ∨ e ( a ) )
− P ( m (cid:48) ) ≥ P ( m (cid:48)(cid:48)
∨ e ( a ) )
− P ( m (cid:48)(cid:48) ) for any m (cid:48) ˙
≤ m (cid:48)(cid:48) , m (cid:48)
∧ e ( a ) = 0 , and m (cid:48)(cid:48)
∧ e ( a ) = 0 .
Proof.
According to (3),
[Equation]
Let α ( m ) (cid:44) arg
[Equation] [Equation]
m T
[Equation]
≤ B s , m T ˙ ≤ m (cid:3) return the optimized mask m T given any m , Λ m (cid:44) min( α ( m ) (cid:12) s T ) be the minimal saliency of the network elements selected at iteration T for P ( m ) .
Then, we have
[Equation]
The second equality is due to the fact that the network element v aT would only replace the lowest included element in m T in order to maximize the objective.
Then,
[Equation]
Given m (cid:48) ˙ ≤ m (cid:48)(cid:48) , we have Λ m (cid:48) ≤ Λ m (cid:48)(cid:48) since m T ˙ ≤ m in α ( m (cid:48) ) is a tighter constraint than that in α ( m (cid:48)(cid:48) ) .
Consequently, we can get s at − Λ m (cid:48) ≥ s at − Λ m (cid:48)(cid:48) , and thus
[Equation]
C P ROOF OF L EMMA
We restate Lemma 1 for clarity.
Lemma 1.
Let e ( i ) be an M -dimensional one-hot vectors with the i -th element be 1 .
∀ 1 ≤ a, b ≤ M ; m ∈ { 0 , 1 } M s.t.
m
∧ ( e ( a ) ∨ e ( b ) ) = 0 .
Given a vector of observed saliency ˜ s 1: t , if µ aT | 1: t ≥ µ bT | 1: t and µ aT | 1: t ≥ 0 , then
E p
[Equation]
T
[Equation] [Equation]
where θ (cid:44) (cid:113) σ aaT | 1: t + σ bbT | 1: t − 2 σ abT | 1: t , ν (cid:44) µ bT | 1: t − µ aT | 1: t , and Φ and φ are standard normal
CDF and PDF, respectively.
To prove this Lemma, we prove the following ﬁrst:
Lemma 3.
E p
[Equation]
s
[Equation]
≤ E [max
[Equation]
s bT − s aT
[Equation] [Equation]
Proof.
Due to (9), we have
[Equation]
The equality (11) is achieved by adding Λ m − s aT in each term of the two max functions in (10).
The inequality (12) can be proved by considering the following two cases:
If Λ m − s aT ≥ 0 , then
[Equation]
If Λ m − s aT < 0 , then
[Equation]
s
[Equation]
s aT
[Equation]
s
[Equation]
Next we utilize a well known bound regarding the maximum of two Gaussian random variables (Nadarajah & Kotz, 2008), which we restate:
Lemma 4.
Let s a , s b be Gaussian random variables with means µ a , µ b and standard deviations σ a , σ b , then E [max( s a , s b )] ≤ µ a Φ (cid:0) µ b − µ a θ (cid:1) + µ b Φ (cid:0) µ b − µ a θ (cid:1) + θφ (cid:0) µ b − µ a θ (cid:1) where θ (cid:44) (cid:112) [ σ b ] 2 + [ σ a ] 2 − 2 cov ( s b , s a ) and Φ , φ are standard normal CDF and PDF respectively.
Then,
[Equation]
The ﬁrst inequaltiy follows from Lemma 4.
The second inequaltiy is due to Φ (cid:0) µ bT | 1: t − µ aT | 1: t θ (cid:1) ≤and µ aT | 1: t ≥ 0 .
D D YNAMIC PENALTY SCALING AS A FEEDBACK LOOP
We designed a feedback loop to automatically determine λ t during early pruning.
A proportional feedback loop can be deﬁned as follows 19 :
[Equation] [Equation]
where K p ≥ 0 is a proportional constant which modulates λ t according to a signed measure of error e ( · ) at time t .
Note that λ t ≥ λ as e ( t ) ≥ 0 , and the opposite occurs if e ( t ) ≤ 0 , which allows the error to serve as feedback to determine λ t .
Implicitly, λ t asserts some control over e ( t + 1) , and thus closing the feedback loop.
Traditional PID approaches to determine K p do not work in our case as λ may vary over several orders of magnitude.
Consequently, a natural choice for K p is λ itself which preserves the same order of magnitude between K p and λ :
[Equation]
Here we make two decisions to adapt the above to our task.
First, as λ is likely to be extremely small, we use exponentiation, as opposed to multiplication.
Secondly as λ ≤ 1 in practice, we use 1 − e ( t ) as an exponent:
[Equation]
The above derivation is complete with our deﬁnition of e ( t ) :
[Equation]
The above determines error by the discrepancy between the anticipated compute required to complete training ( T − t ) || m t || 0 , vs. the remaining budget B t,c with e ( t ) =
if the two are equal.
This is a natural measure of feedback for λ as we expect the two to be equal if λ is serving well to early prune the network.
E C OMPARISON WITH P RUNE T RAIN
We compare with PruneTrain (Lym et al., 2019) in Table 5.
PruneTrain uses an orthogonal technique of dynamically increasing the minibatch size to achieve further wall time improvements.
This prevents accurate wall time comparisons between BEP and PruneTrain.
To compare with PruneTrain which [Table] [Table]
Random variable representing the saliency measurement of network
[Table]
Sequence of
[Table]
The realization of random variable s
[Table]
t
[Table]
m
[Table]
Pruning mask at time t
[Table]
Trained network sparsity budget.
[Table]
Computational effort budget at time t .
µ at (cid:48) | 1: t
E [ s at (cid:48) | ˜ s 1: t ] σ aa (cid:48) t (cid:48) | 1: t cov [ s at (cid:48) , s a (cid:48) t (cid:48)
| ˜ s 1: t ] does not constrain the trained network size (3b), we train ResNet- 50 under equivalent inference cost as a network trained by PruneTrain. To compute train/inference cost (FLOPs) for a convolutional layer, we used a formula deﬁned in Molchanov et al.
(2017) A.1:
[Equation]
where H , W , C in are input height, width, and channels respectively, K is the convolutional kernel size, and C out is the number of output channels of the layer. Under equivalent inference cost, BEP 1e − 1 outperforms PruneTrain in Top-1 performance. We also ﬁnd that BEP 1e − 1 and BEP 1e − 4 consumes fewer training FLOPs when compared to baseline. It should be noted that PruneTrain does not provide a mechanism to constrain the trained network size, thus it is unclear how to utilize it in order to solve the early pruning problem (3), (4).
F T ABLE OF NOTATIONS
We list a table of notations used elsewhere in the paper in Table 6.
[Table]
AND E XPERIMENTAL D ETAILS G. GP VS . MOGP LOG - LIKELIHOOD ON CIFAR- 10 DATASET
Table 7 presents the results of the experiment in Section 4.1 for the CIFAR- 10 dataset.
G
E XPERIMENTAL DETAILS
To train our CIFAR- 10 and CIFAR- 100 models we used an Adam optimizer (Kingma & Ba, 2015) with an initial learning rate of 0 . 001 .
The learning rate used an exponential decay of k = 0 . 985 , and a batch size of 32 was used.
Training was paused three times evenly spaced per epoch.
During this pause, we collected saliency measurements using 40% of the training dataset.
This instrumentation subset was randomly select from the training dataset at initialization, and remained constant throughout the training procedure.
We performed data preprocessing of saliency evaluations into a standardized [0 , 10] range.
20 We used (8) to measure saliency of neurons/convolutional ﬁlters.
For the convolutional layers we used 12 latent MOGP functions.
For the dense layer we used 4 latent MOGP functions.
For our ResNet- 50 model we used an SGD with Momentum optimizer with an initial learning rate of 0 . 1 .
The learning rate was divided by ten at t =
[30 , 60 , 80] epochs.
We collected saliency data every 5 iterations of SGD, and averaged them into buckets corresponding to 625 iterations of SGD to form our dataset.
We used a minimum of 4 latent functions per MOGP, however this was dynamically increased if the model couldn’t ﬁt the data up to a maximum of 15 .
We sampled 10 K points from our MOGP model to estimate ∆( · ) for CIFAR- 10 /CIFAR- 100 .
For
ResNet we sampled 15 K points.
We repeated experiments 5 times for reporting accuracy on CIFAR10 /CIFAR- 100 .
G. P RUNING ON R ES N ET
ResNet architecture is composed of a sequence of residual units: Z (cid:96) (cid:44) F ( P (cid:96) − 1 )+ P (cid:96) − 1 , where P (cid:96) −is the output of the previous residual unit Z (cid:96) − 1 and ‘ + ’ denotes elementwise addition.
Internally, F is typically implemented as three stacked convolutional layers: F ( P (cid:96) − 1 ) (cid:44) [ z (cid:96) 3 ◦ z (cid:96) 2 ◦ z (cid:96) 1 ] ( P (cid:96) − 1 )
where z (cid:96) 1 , z (cid:96) 2 , z (cid:96) 3 are convolutional layers.
Within this setting we consider convolutional ﬁlter pruning.
Although z (cid:96) 1 , z (cid:96) 2 may be pruned using the procedure described earlier.
Pruning z (cid:96) 3 requires a different procedure.
Due to the direct addition of P (cid:96) − 1 to F ( P (cid:96) − 1 ) , the output dimensions of Z (cid:96) −and
z (cid:96) 3 must match exactly.
Thus a ResNet architecture consists of sequences of residual units of length B with matching input/output dimensions: ζ (cid:44) [ Z (cid:96) ] (cid:96) =1 ,...,
B , s.t. dim ( P 1 ) =
dim ( P 2 ) = . . .
= dim ( P B ) .
We propose group pruning of layers [ z (cid:96) 3 ] (cid:96) =1 ,...,B where ﬁlters are removed from all z (cid:96) 3 in a residual unit sequence in tandem.
We deﬁne s ([ ζ, c ]) (cid:44) (cid:80) B(cid:96)
=1 s ([ (cid:96) 3 , c ]) , where s ( · ) is deﬁned for convolutional layers as in (8).
To prune the channel c from ζ , we prune it from each layer in [ z (cid:96) 3 ] (cid:96) =1 ,...,B .
Typically we pruned sequence channels less aggressively than convolutional ﬁlters as these channels feed into several convolutional layers.
[Figure]
G. D ATA PREPROCESSING
We followed the same data preprocessing procedure for both our small scale and ImageNet experiments. To standardize the saliency measurements for a training dataset ˜ s 1: t in our modeling experiments we clip them between 0 and an upper bound computed as follows: ub (cid:44) percentile (˜ s 1: t , 95) × 1 . 3 . This procedure removes outliers. We used 1 . 3 as a multiplier, as this upper bound is used to transform test dataset as well, which may have higher saliency evaluations.
After clipping the training data, we perform a trend check for each element v a by ﬁtting a Linear
Regression model to the data ˜ s a 1: t .
For ˜ s a 1: t with an increasing trend (i.e., the linear regression model has positive slope) we perform the transformation ˜ s a 1: t = ub − ˜ s a 1: t . The reasoning behind this is that the exponential kernel strongly prefers decaying curves. After this preprocessing, we scale up the saliency measurements to a [0 , 10] range: ˜ s 1: t = ˜ s 1: t × 10 .
We found that without scaling to larger values, log-likelihood of our models demonstrated extremely high positive values due to small values of unscaled saliency measurements.
We transform the test data in our modeling experiments ˜ s t +1: T with the same procedure using the same ub and per-element v a regression models as computed by the training data.
We measure log-likelihood after this transformation for both the test dataset in our small scale experiments.
During the BEP Algorithm, the same steps are followed, however we inverse the trend check transformation ( ˜ s a 1: t = ub − ˜ s a 1: t ) on the predicted MOGP distribution of s T prior to sampling for estimation of ∆( · ) .