D OUBLE V ITERBI : W EIGHT E NCODING FOR H IGH C OMPRESSION R ATIO AND F AST O N -C HIP R ECONSTRUCTION FOR D EEP N EURAL N ETWORK
Anonymous authors
Paper under double-blind review
A BSTRACT
Weight pruning has been introduced as an efﬁcient model compression technique.
Even though pruning removes signiﬁcant amount of weights in a network, memory requirement reduction was limited since conventional sparse matrix formats require signiﬁcant amount of memory to store index-related information.
Moreover, computations associated with such sparse matrix formats are slow because sequential sparse matrix decoding process does not utilize highly parallel computing systems efﬁciently.
As an attempt to compress index information while keeping the decoding process parallelizable, Viterbi-based pruning was suggested.
Decoding non-zero weights, however, is still sequential in Viterbi-based pruning.
In this paper, we propose a new sparse matrix format in order to enable a highly parallel decoding process of the entire sparse matrix.
The proposed sparse matrix is constructed by combining pruning and weight quantization.
For the latest RNN models on PTB and WikiText-2 corpus, LSTM parameter storage requirement is compressed 19 × using the proposed sparse matrix format compared to the baseline model.
Compressed weight and indices can be reconstructed into a dense matrix fast using Viterbi encoders.
Simulation results show that the proposed scheme can feed parameters to processing elements 20 % to 106 % faster than the case where the dense matrix values directly come from DRAM.
I NTRODUCTION
Deep neural networks (DNNs) require signiﬁcant amounts of memory and computation as the number of training data and the complexity of task increases (Bengio & Lecun, 2007).
To reduce the memory burden, pruning and quantization have been actively studied.
Pruning removes redundant connections of DNNs without accuracy degradation (Han et al., 2015).
The pruned results are usually stored in a sparse matrix format such as compressed sparse row (CSR) format or compressed sparse column (CSC) format, which consists of non-zero values and indices that represent the location of non-zeros.
In the sparse matrix formats, the memory requirement for the indices is not negligible.
Viterbi-based pruning (Lee et al., 2018) signiﬁcantly reduces the memory footprint of sparse matrix format by compressing the indices of sparse matrices using the Viterbi algorithm (Forney, 1973).
Although Viterbi-based pruning compresses the index component considerably, weight compression can be further improved in two directions.
First, the non-zero values in the sparse matrix can be compressed with quantization.
Second, sparse-to-dense matrix conversion in Viterbi-based pruning is relatively slow because assigning non-zero values to the corresponding indices requires sequential processes while indices can be reconstructed in parallel using a Viterbi Decompressor (VD).
Various quantization techniques can be applied to compress the non-zero values, but they still cannot reconstruct the dense weight matrix quickly because it takes time to locate non-zero values to the corresponding locations in the dense matrix.
These open questions motivate us to ﬁnd a non-zero value compression method, which also allows parallel sparse-to-dense matrix construction.
The contribution of this paper is as follows
(a) To reduce the memory footprint of neural networks further, we propose to combine the Viterbibased pruning (Lee et al., 2018) with a novel weight-encoding scheme, which also uses the Viterbi-based approach to encode the quantized non-zero values.
(b) We suggest two main properties of the weight matrix that increase the probability of ﬁnding "good" Viterbi encoded weights.
First, the weight matrix with equal composition ratio of ‘0’ and ‘1’ for each bit is desired.
Second, using the pruned parameters as "Don’t Care" terms increases the probability of ﬁnding desired Viterbi weight encoding.
(c) We demonstrate that the proposed method can be applied to Recurrent Neural Networks (RNNs) and Convolutional Neural Networks (CNNs) with various sizes and depths.
(d) We show that using the same Viterbi-based approach to compress both indices and non-zero values allows us to build a highly parallel sparse-to-dense reconstruction architecture.
Using a custom cycle-simulator, we demonstrate that the reconstruction can be done fast.
R ELATED W ORKS
DNNs have been growing bigger and deeper to solve complex nonlinear tasks.
However, Denil et al.
(2013) showed that most of the parameters in neural networks are redundant.
To reduce the redundancy and minimize memory and computation overhead, several weight reduction methods have been suggested.
Recently, magnitude-based pruning methods became popular due to its computational efﬁciency (Han et al., 2015).
Magnitude-based pruning methods remove weights according to weight magnitude only and retrain the pruned network to recover from accuracy loss.
The method is scalable to large and deep neural networks because of its low computation overhead.
Han et al.
(2015) showed 9 × -13 × pruning rate on AlexNet and VGG-16 networks without accuracy loss on ImageNet dataset.
Although the compression rate was high, reduction of actual memory requirement was not as high as the compression rate because conventional sparse matrix formats, such as CSR and CSC, must use large portion of memory to store the indices of surviving weights.
Lee et al.
(2018) succeeded in reducing the amount of index-related information using a Viterbi-algorithm based pruning method and corresponding custom sparse matrix format.
Lee et al.
(2018) demonstrated 38.1% memory reduction compared to Han et al.
(2015) with no accuracy loss.
The memory reduction was limited, however, due to uncompressed non-zero values.
Several weight quantization methods were also suggested to compress the parameters of neural networks.
Courbariaux et al.
; Li et al.
; Rastegari et al.
(2016) demonstrated that reducing the weights to binary or ternary was possible, but the accuracy loss of the binary neural networks was signiﬁcant.
Zhou et al.
(2016) reduced the bit resolution of weights to binary, activations to 2 bits and gradients to 6 bits with 9.8 % top-1 accuracy loss on AlexNet for ImageNet task.
Guo et al.
(2017) demonstrated a binary-weight AlexNet with 2.0% top-1 accuracy loss, achieving ∼ 10 × compression rate.
Xu et al.
(2018) showed that RNNs can also be quantized to reduce the memory footprint.
By quantizing the weight values to 3 bits with proposed method, the memory footprint of RNN models were reduced ∼ 10.5 × with negligible performance degradation.
Han et al.
(2016b) suggested to combine pruning with weight quantization to achieve higher compression rate.
The results showed 35 × increase in compression rate on AlexNet.
However, the reduction was limited since the memory requirement of index-related information was only slightly improved with Huffman coding.
Although several magnitude-based pruning methods showed high compression rate, computation time did not improve much, because it takes time to decode the sparse matrix formats that describe irregular weight indices of pruned networks.
Han et al.
(2016a; 2017) suggested to use dedicated hardware, custom sparse matrix formats, and dedicated pruning methods to accelerate the computation even after pruning.
Hanson & Pratt (1989); Yu et al.
(2017) tried to accelerate the computation by limiting the irregularity of weight indices.
By pruning neurons or feature maps, pruned weight matrices could maintain the dense format.
These approaches successfully reduced the number of computation of neural networks, but the compression rate was limited due to additional pruning conditions.
Although
Lee et al.
(2018) could use the Viterbi encoder to construct the index matrix fast, the process of pairing the non-zero weight values with the corresponding indices is still sequential, and thus relatively slow.
W EIGHT P RUNING AND Q UANTIZATION USING D OUBLE -V ITERBI APPROACH
Figure 1 illustrates the ﬂowchart of the proposed compression method.
Viterbi-based pruning (Lee et al., 2018) is applied ﬁrst, and the pruned matrix is quantized using alternating multi-bit quantization method (Xu et al., 2018).
Quantized binary code matrices are then encoded using the Viterbi-based approach, which is similar to the one used in pruning.
3. V ITERBI - BASED PRUNING FOR SPARSE MATRIX INDEX COMPRESSION
As the ﬁrst step of the proposed weight encoding scheme, we compress the indices of the non-zero values in sparse weight matrix using the Viterbi-based pruning (Figure 1) (Lee et al., 2018).
In this scheme, Viterbi algorithm is used to select a pruned index matrix which minimizes the accuracy degradation among many candidates which a Viterbi decompressor can generate.
While the memory footprint of the index portion is signiﬁcantly reduced by the Viterbi-based pruning, the remaining non-zero values after pruning still require non-negligible memory when high-precision bits are used.
Hence, quantization of the non-zero values is required for further reduction of the memory requirement.
Appendix A.1 explains the Viterbi-based pruning in detail.
3. M ULTI - BIT QUANTIZATION AFTER V ITERBI - BASED PRUNING
After Viterbi-based pruning is ﬁnished, the alternating multi-bit quantization (Xu et al., 2018) is applied to the sparse matrix (Figure 1).
As suggested in Xu et al.
(2018), real-valued non-zero weights are quantized into multiple binary codes { b i } ki =1 ∈ {− 1 , +1 } .
Detailed algorithm is explained in
Appendix A.2.
In addition to the high compression capabilities, another important reason we chose the alternating quantization is that the output distribution of the method is well suited to the Viterbi algorithm, which is used to encode the quantized non-zero values.
Detailed explanation is given in Section 3.3.
3. E NCODING BINARY WEIGHT CODES USING THE V ITERBI ALGORITHM
A sparse matrix that is generated by Viterbi-based pruning and quantization can be represented using the Viterbi Compression Matrix (VCM) format (Lee et al., 2018).
A sparse matrix stored in VCM format requires much smaller amount of memory than the original dense weight matrix does.
However, it is difﬁcult to parallelize the process of reconstructing sparse matrix from the representation in VCM format, because assigning each non-zero value to its corresponding index requires a sequential process of counting ones in indices generated by the Viterbi encoder.
To address this issue, we encode binary weight codes { b i } ki =1 as { ˆ b i } ki =1 in addition to the indices, based on the same Viterbi algorithm (Forney, 1973).
By using similar VD structures (Figure 2) to generate both { ˆ b i } ki =1 and indices, we can generate both { ˆ b i } ki =1 and corresponding indices at the same time; thereby parallel sparse-to-dense matrix conversion becomes possible as shown in Figure 3.
While using VD structures to generate binary weight codes allows parallel sparse-to-dense matrix conversion, it requires the quantization method to satisfy a speciﬁc condition to minimize accuracy loss after Viterbi-based encoding.
It is known that the VD structure acts as a random number generator (Lee & Roy, 2012), which produces ‘0’ and ‘1’ with 50 % probability each.
Thus, generated binary weight codes will be closer to the target binary weight codes if the target binary weight code matrix also consists of equal number of ‘0’ and ‘1’.
Interestingly, the composition ratio of ‘-1’ and ‘+1’ in each b i , which was generated by the alternating quantization method, is 50 % each.
It is because
[Figure]
(cid:1)(cid:2)(cid:3)(cid:2)(cid:3)(cid:2)(cid:3)(cid:2)(cid:3)(cid:2)(cid:4)(cid:1)(cid:2)(cid:5)(cid:2)(cid:5)(cid:2)(cid:3)(cid:2)(cid:3)(cid:2)(cid:4)(cid:1)(cid:2)(cid:3)(cid:2)(cid:3)(cid:2)(cid:5)(cid:2)(cid:3)(cid:2)(cid:4)(cid:1)(cid:2)(cid:3)(cid:2)(cid:5)(cid:2)(cid:3)(cid:2)(cid:3)(cid:2)(cid:4) (cid:1)(cid:2)(cid:2)(cid:3)(cid:2)(cid:2)(cid:2)(cid:3)(cid:2)(cid:2)(cid:2)(cid:3)(cid:2)(cid:2)(cid:2)(cid:3)(cid:2)(cid:4)(cid:1)(cid:2)(cid:3)(cid:6)(cid:7)(cid:2)(cid:3)(cid:6)(cid:7)(cid:2)(cid:2)(cid:3)(cid:2)(cid:2)(cid:2)(cid:3)(cid:2)(cid:4)(cid:1)(cid:2)(cid:2)(cid:3)(cid:2)(cid:2)(cid:2)(cid:3)(cid:2)(cid:2)(cid:3)(cid:6)(cid:8)(cid:2)(cid:2)(cid:3)(cid:2)(cid:4)(cid:1)(cid:2)(cid:2)(cid:3)(cid:2)(cid:2)(cid:3)(cid:6)(cid:8)(cid:2)(cid:2)(cid:3)(cid:2)(cid:2)(cid:2)(cid:3)(cid:2)(cid:4)
[Table]
[Figure]
the weights in DNNs are generally initialized symmetrically with respect to ‘0’ (Glorot & Bengio, 2010; He et al., 2015) and the distribution is maintained even after training (Lin et al., 2016).
The preferable output distribution of the alternating quanatization implies that the probability of ﬁnding an output matrix ˆ b
i close to b i with the Viterbi algorithm is high.
For comparison, we also tried to generate Viterbi output which is close to the conventional k-bit quantized weight instead of the weight from the alternating quantization.
We observed that such a scheme produced signiﬁcant drop in accuracy because in this case there is no guarantee for equal composition ratio of ‘0’ and ‘1’ in the weight matrix unlike alternating quantization.
Another important idea to increase the probability of ﬁnding "good" Viterbi encoded weight is to consider the pruned parameters in b i as "Don’t Care" terms (Figure 4).
The "Don’t Care" elements can have any values when ﬁnding ˆ b i , because they will be masked by the zero values in the index matrix generated by the Viterbi pruning.
[Equation]
(cid:1) (cid:1)(cid:2) (cid:3) (cid:1) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:4) (cid:1) (cid:1)(cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:3) (cid:2) (cid:2) (cid:2) (cid:1) (cid:2) (cid:4) (cid:1) (cid:1)(cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:3) (cid:1) (cid:1)(cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:3) (cid:1) (cid:1)(cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:3) (cid:1) (cid:1)(cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:3) (cid:1) (cid:1)(cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:2) (cid:1) (cid:2) (cid:3) (cid:1)
[Figure]
Next, let us describe how we use the Viterbi algorithm for weight encoding.
We select the ˆ b i that best matches with b i among all possible ˆ b i cases that the VD can generate, as follows.
We ﬁrst construct a trellis diagram as shown in Figure 5.
The trellis diagram is a state diagram represented with time index T .
A state number is represented with Flip-Flop (FF) values, where the rightmost FF value is the most signiﬁcant bit (MSB).
1 Each transition with a 1-bit input from a state generates the corresponding multiple output bits.
A cost function for each transition using path and branch metrics is set and computed in the next step.
The branch metric λ
i,jt is the cost of traveling along a transition from a state i to the successor state j at the time index t .
The path metric is expressed as
[Equation]
where i 1 and i 2 are two predecessor states of j .
Equation 1 denotes that one of the two possible transitions is selected to maximize the accumulated value of branch metrics.
The branch metric is deﬁned as
[Equation]
where b i,j,mt is the value of binary codes according to the m th VD output at time index t , o i,j,mt is the value of the m th VD output at time index t , and N o is the number of outputs generated by the VD at each time step.
{− 1 , +1 } in the binary codes corresponds to { 0 , 1 } in the VD output in equation 2.
Equation 2 maximizes the number of VD outputs that exactly match with corresponding binary codes while ignoring the pruned parameters (Figure 4).
When the last time index is reached, the state with the maximum path metric is selected.
Previous states connected by surviving branches are traced while corresponding o i,j,mt of each branch is recorded as ˆb i,j,mt .
Each binary weight code b i is encoded as ˆb i with a compression ratio of 1/ N o using this scheme.
T
T+   5
T
T+   29
T
T+ {out1,out2,out3,out4}
CurrentState
NextState
Transition by Transition by
State number
3. R ETRAINING
To maintain the accuracy, the number of incorrect bits in the encoded binary code ˆ b i compared to the original binary code b i needs to be minimized.
Thus, we retrain the network with ˆ W PQ =
(cid:16)(cid:80)
{+ki =
+}
α i ˆb i (cid:17) (cid:12) M ( M is the index matrix of non-zeros in W ), apply the alternating quantization, and then perform the Viterbi encoding repeatedly (Figure 1).
By repeating the retraining, quantization, and Viterbi encoding, the number of incorrect bits between ˆ b i and b i can be reduced because the parameters in the network are ﬁne-tuned close to parameters in ˆ W PQ .
During the retraining period, we apply the straight-through estimate (Rastegari et al., 2016), i.e.
[Equation]
∂C∂W as adopted in Xu et al.
After the last Viterbi encoding is ﬁnished, small amount of components in ˆ b i can be still different from the corresponding values in b i .
To maintain the accuracy, location data for the incorrect components are stored separately and are used to ﬂip the corresponding VD encoded bits during on-chip weight reconstruction period.
In our experiments, the memory requirement for the correction data was negligible.
After the retraining is ﬁnished, we can obtain a compressed parameter in Viterbi Weight Matrix (VWM) format, which includes { α i } ki =1 , compressed input to generate { ˆb i } ki =1 , compressed index in VCM format, and indices where { ˆb i } ki =1 (cid:54) =
{ b i } ki =1 .
Note that entire training process used the training dataset and the validation dataset only to decide the best compressed weight data.
The accuracy measurement for the test dataset was done only after training is ﬁnished so that any hyperparameter was not tuned on the test dataset.
E XPERIMENTAL R ESULTS 4. R ECURRENT NEURAL NETWORKS (RNN) FOR LANGUAGE MODELING
We ﬁrst conduct experiments on Penn Tree Bank (PTB) corpus (Marcus et al., 1993).
We use the standard split version of PTB corpus with 10K vocabulary (Mikolov, 2012), and evaluate the performance using perplexity per word (PPW).
We pretrain the RNN model 3 which contains 1 layer of LSTM with 600 memory units, then prune the parameters of LSTMs with 80 % pruning rate using the Viterbi-based pruning technique 4 and retrain the model.
Then, we quantize the parameters of
LSTMs using alternating quantization technique, encode the binary weight codes by using the Viterbi algorithm, and retrain the model.
We repeat the quantization, binary code encoding, and retraining process 5 times.
Number of quantization bits: We quantize the LSTM model with different numbers of quantization bits k with the ﬁxed N o = 5 .
As k increases, PPW is improved, but the memory requirement for parameters is also increased (Table 1).
Note that k
= 3 is the minimum number of bits that minimizes the model size without PPW degradation.
Compared to Lee et al.
(2018), further quantization and
Viterbi-based compression reduce the parameter size by 78 % to 90 % (Table 1).
Number of VD outputs: We compress the binary weight codes with different number of VD outputs
N o in case of k = 3 .
As N o increases, PPW degrades while the memory requirement for parameters is increased (Table 1).
Large N o implies that the binary weight codes are compressed with high compression ratio 1 /N
o , but the similarity between ˆb i and b i decreases.
The optimal N o is 100/(100pruning rate (%)) , where the average number of survived parameters per N o serial parameters isstatistically, which results in no model performance degradation.
Effectiveness of "Don’t Care": To verify the effectiveness of using the "Don’t Care" elements, we apply our proposed method on the original network and pruned one.
While the pruned network maintains the original PPW after applying our proposed compression method, applying our method to the dense network degrades PPW to 102.6.
This is because the ratio of incorrect bits between ˆ b i and b i decreases from 28.3 % to 1.7 % when we use the sparse b i .
Therefore, combination of the
Viterbi pruning and alternating quantization increases the probability of ﬁnding
ˆ b
i close to b
i using the VD for weight encoding, which results in no PPW degradation.
[Table]
The latest RNN for language modeling: We further test our proposed method on the latest RNN model (Yang et al., 2018), which shows the best perplexity on both PTB and WikiText-2 (WT2) corpus.
We prune 75 % of the parameters in three LSTMs with the same condition as we prune the above 1-layer LSTM model, and quantize them to 3 bits ( k = 3 ).
Note that we do not apply ﬁne-tuning and dynamic evaluation (Krause et al., 2017) in this experiment.
The compression result in Table 2 shows that the memory requirements for the models are reduced by 94.7 % with our
VWM format on both PTB and WT2 corpus without PPW degradation.
This result implies that our proposed compression method can be applied regardless of the depth and size of the network.
Detailed experiment settings and compression results are described in Appendix A.3.
In addition, we extend our proposed method to the RNN models for machine translation (Wu et al., 2016), and its experimental results are presented in Appendix A.
[Table] [Table]
C ONVOLUTIONAL NEURAL NETWORKS (CNN) FOR IMAGE CLASSIFICATION
We also apply our proposed method to a CNN, VGG-9 (2 × 128C3 - 2 × 256C3 - 2 × 512C3 - 2 × 1024FC - 10SM 5 ) on CIFAR-10 dataset to verify the proposed technique is valid for other types of DNNs.
We randomly select 5 K validation images among 50 K training images in order to observe validation error during retraining process and measure the test error after retraining.
We use k = 3 for all layers.
Optimal N o for each layer is chosen based on the pruning rate of the parameters; N o =for convolutional layers, N o = 25 for the ﬁrst two fully-connected layers, and N o = 5 for the last fully-connected layer.
We also compute the memory requirement for other compression methods.
Experimental results on VGG-9 is found in Table 3.
Compared to Han et al.
(2016b), the VWM format generated by the proposed scheme has 39 % smaller memory footprint due to the compressed indices, smaller number of bits for quantization, and encoded binary weight codes.
This experiment on CIFAR-10 shows that our proposed method can be applied to DNNs with various types and sizes.
4. A NALYSIS ON RECONSTRUCTION SPEED
We built a cycle-level simulator for the weight matrix reconstruction process of the proposed format to show that the sparse matrix-matrix multiplications with the proposed method can be done fast with parallel reconstruction of dense matrix.
In the simulator, baseline structure feeds two dense input matrices to processing elements (PEs) using raw data fed by DRAM (Figure 6a), while the proposed structure reconstructs both index masks and binary codes using the highly compressed data fed by
DRAM and sends the reconstructed values to PEs (Figure 6b).
Both index masks and binary codes are reconstructed by several Viterbi encoders in parallel, and bit errors in binary codes are corrected in a serial manner using the small number of ﬂip-bit related data, which are received from DRAM.
Simulation results show that the feeding rate of the proposed scheme is 20.0-106.4 % higher than the baseline case and 10.3-40.5 % higher than Lee et al.
(2018), depending on the pruning rate (Figure 6c).
The gain mainly comes from the high compression rate and parallel reconstruction process of the proposed method.
As shown in Figure 6c, higher sparsity leads to higher feeding rate.
Higher sparsity allows using many VD outputs for the index N ind , and increasing N ind leads to faster reconstruction.
Also, the reconstruction rate of binary codes becomes higher with reduced number of non-zero values and corresponding bit corrections.
[Table]
ind =
C ONCLUSIONS
We proposed a DNN model compression technique with high compression rate and fast dense matrix reconstruction process.
We adopted the Viterbi-based pruning and alternating multi-bit quantization technique to reduce the memory requirement for both non-zeros and indices of sparse matrices.
Then, we encoded the quantized binary weight codes using Viterbi algorithm once more.
As the non-zero values and the corresponding indices are generated in parallel by multiple Viterbi encoders, the sparse-to-dense matrix conversion can be done very fast.
We also demonstrated that the proposed scheme signiﬁcantly reduces the memory requirements of the parameters for both RNN and CNN.
A A PPENDIX A. P RUNING USING THE V ITERBI ALGORITHM
In Viterbi-based pruning scheme, the binary outputs generated by a Viterbi Decompressor (VD) are used as the index matrix that indicates whether a weight element is pruned (‘0’) or not (‘1’).
Suppose the number of elements in a target weight matrix is q , and the number of outputs generated by a VD at each time step is N ind , then only 2 q /N ind binary matrices can be generated by the VD among all 2 q binary matrices.
The index matrix which minimizes the accuracy loss should be selected among binary matrix candidates which VD can generate in this pruning scheme, and the Viterbi algorithm is used for this purpose.
The overall pruning process is similar to the binary weight encoding process using the Viterbi algorithm in Section 3.3.
First, Trellis diagram (Figure 5) of the VD which is used for pruning is constructed, and then the cost function is computed by using the path metric and the branch metric.
The same path metric shown in Equation 1 in Section 3.3 is used to select the branch which maximizes the path metric between two connected branches from the previous states.
On the other hand, a different branch metric λ
i,jt is used for pruning, which is expressed as:
[Equation]
tanh
[Equation]
when survived
[Equation]
when pruned
[Equation]
where W i,j,mt is the magnitude of a parameter at the m th VD output and time index t , normalized by the maximum absolute value of all elements in target weight matrix, and TH p is the pruning threshold value determined heuristically.
As β i,j,mt gives additional points (penalties) to the parameters with large magnitude to survive (be pruned), the possibility to prune small-magnitude parameters is maximized.
S 1 and S 2 are the scaling factors which is empirically determined.
(Lee et al.
(2018) uses 5.0 and 10 4 each).
After computing the cost function through the whole time steps, the state with the maximum path metric is chosen, and we trace the previous state by selecting the surviving branch and corresponding indices backward until the ﬁrst state is reached.
The ideal pruning rate of the Viterbi-based pruning is 50 %, because the VD structures act like random number generator and the probability to generate ‘0’ or ‘1’ is 50 % each.
For various pruning rates, comparators and comparator threshold value, TH c , are used.
A N C -bit comparator receives N c
VD outputs and generates 1-bit result whether the value made by the combination of the received VD outputs (e.g. { out 1 , out 2 , · · · , out N ind } where out i indicates the i th VD output) is greater than TH c or not.
For example, suppose a 4-bit comparator is used to the VD in Figure 1 and TH c = 3 , then the probability for the comparator to generate ‘1’ is 25%(= (3 + 1) / 2 4 ) and this percentage is the target pruning rate.
Comparators and TH c control the value of pruning rates and the index compression ratio decreases by 1 /N c times.
It is reported that a low N ind is desired to prune weights of convolutional layers while high N ind can be used to prune the weights of fully-connected layers because of the trade-off between the index compression ratio and the accuracy (Lee et al., 2018).
Thus, in our paper, we use N ind = 50 and
N c = 5 to prune weights of LSTMs and fully-connected layers in VGG-6 on CIFAR-10.
On the other hand, we use N ind = 10 and N c
= 5 to prune weights of convolutional layers in VGG-6 on
CIFAR-10.
A. A LTERNATING M ULTI - BIT Q UANTIZATION ON S PARSE M ATRIX
for i do end if det (cid:0) B T B (cid:1) (cid:54) =
then for t
1 to T do
Construct v are set to end end
←
Pruned components in { b i } ki =1 are set to ‘+1’ because b i ∈ {− 1 , +1 } n .
Algorithm 1 explains the multi-bit quantization process applied to a sparse matrix.
Given { α i } ki =1 with α 1 ≥ α 2 · · · ≥ α k − 1 ≥ α k ≥ 0 and the number of quantization bits k , each non-zero value in a sparse weight matrix w is quantized to a value v ∈ v = {− (cid:80) ki
=
α i , − (cid:80) k − 1 i − 1 α i + α k , · · · , (cid:80) k − 1 i − 1 α
i − α k , (cid:80) ki
=1 α i } .
Algorithm 1 is a derivative of the alternating multi-bit quantization algorithm
[24] with some consideration for sparse matrix.
First, { α i } ki =1 is initialized with the average norm-1 value of non-zeros in w instead of the average norm-1 value of entire elements in a dense matrix, which was the case in [24].
Also, if the inverse matrix of B T B does not exist due to high pruning rate, Algorithm 1 does not proceed to the second alternating quantization step.
Note that the model performance was not degraded much without running the second quantization step.
Pruned components are represented with ‘0’ during the quantization.
After the quantization, { b i } ki =1 for the pruned components are set to ‘+1’ because b i ∈ {− 1 , +1 } n .
It does not matter whether pruned components are represented as ‘-1’ or ‘+1’, because they will be eventually masked by the binary index matrix indicating the location of non-zeros.
A. D ETAILED C OMPRESSION RESULTS OF THE LATEST RNN FOR LANGUAGE MODELING
The RNN model in Yang et al.
(2018) is composed of three LSTM layers, and use various learning techniques such as mixture-of-softmaxes (MoS) to achieve better perplexity.
As shown in Table A and Table A2, the parameters in the ﬁrst layer have high sparsity, so we use N o = 6 .
In the remaining layers, however, we use N o = 3 because the parameters are pruned with only about 70 % pruning rate.
We repeat the process of quantization, binary code encoding
[Table]
and retraining only once.
[Table] [Table]
A. R ECURRENT N EURAL N ETWORKS (RNN) FOR MACHINE TRANSLATION
We also extend our experiments on the RNN models for machine translation (Wu et al., 2016) 6 .
We use the model which consists of an encoder, a decoder and an attention layer.
4-layer LSTMs with 1024 units compose each encoder and decoder.
A bidirectional LSTM (BiLSTM) is used for the ﬁrst layer of the encoder.
The weights of LSTM models are pruned with 75 % pruning rate by the
Viterbi-based pruning techinque, then k = 4 is used for quantization.
Optimal N o values are used according to the sparsity of each LSTM layer (i.e. 3 ≤ N o ≤ 6 is enough to encode binary weight codes with 70 - 83% of sparsity).
The process of quantization, binary code encoding, and retraining is repeated only once in this case, too.
As shown in Table A3 and Table A4, we reduce the memory requirement of each baseline model by 93.5 % using our proposed technique.
This experiment results show that our proposed scheme can be extended to RNNs for other complex tasks.
[Table] [Table]