Title: LOSS-AWARE WEIGHT QUANTIZATION OF DEEP NET-WORKS

Abstract: The huge size of deep networks hinders their use in small computing devices. In this paper, we consider compressing the network by weight quantization. We extend a recently proposed loss-aware weight binarization scheme to ternarization, with possibly different scaling parameters for the positive and negative weights, and m-bit (where m > 2) quantization. Experiments on feedforward and recurrent neural networks show that the proposed scheme outperforms state-of-the-art weight quantization algorithms, and is as accurate (or even more accurate) than the full-precision network.

1. INTRODUCTION:

The last decade has witnessed huge success of deep neural networks in various domains. Examples include computer vision, speech recognition, and natural language processing (LeCun et al., 2015) . However, their huge size often hinders deployment to small computing devices such as cell phones and the internet of things. Many attempts have been recently made to reduce the model size. One common approach is to prune a trained dense network (Han et al., 2015; 2016) . However, most of the pruned weights may come from the fully-connected layers where computations are cheap, and the resultant time reduction is insignificant. Li et al. (2017b) and Molchanov et al. (2017) proposed to prune filters in the convolutional neural networks based on their magnitudes or significance to the loss. However, the pruned network has to be retrained, which is again expensive.

Another direction is to use more compact models. GoogleNet (Szegedy et al., 2015) and ResNet (He et al., 2016) replace the fully-connected layers with simpler global average pooling. However, they are also deeper. SqueezeNet (Iandola et al., 2016) reduces the model size by replacing most of the 3 × 3 filters with 1 × 1 filters. This is less efficient on smaller networks because the dense 1 × 1 convolutions are costly. MobileNet (Howard et al., 2017) compresses the model using separable depth-wise convolution. ShuffleNet (Zhang et al., 2017) utilizes pointwise group convolution and channel shuffle to reduce the computation cost while maintaining accuracy. However, highly optimized group convolution and depth-wise convolution implementations are required. Alternatively, Novikov et al. (2015) compressed the model by using a compact multilinear format to represent the dense weight matrix. The CP and Tucker decompositions have also been used on the kernel tensor in CNNs (Lebedev et al., 2014; Kim et al., 2016) . However, they often need expensive fine-tuning.

Another effective approach to compress the network and accelerate training is by quantizing each full-precision weight to a small number of bits. This can be further divided to two sub-categories, depending on whether pre-trained models are used (Lin et al., 2016a; Mellempudi et al., 2017) or the quantized model is trained from scratch (Courbariaux et al., 2015; Li et al., 2017a) . Some of these also directly learn with low-precision weights, but they usually suffer from severe accuracy deterioration (Li et al., 2017a; Miyashita et al., 2016) . By keeping the full-precision weights during learning, Courbariaux et al. (2015) pioneered the BinaryConnect algorithm, which uses only one bit for each weight while still achieving state-of-the-art classification results. Rastegari et al. (2016) further incorporated weight scaling, and obtained better results. Instead of simply finding the closest binary approximation of the full-precision weights, a loss-aware scheme is proposed in (Hou et al., 2017) . Beyond binarization, TernaryConnect (Lin et al., 2016b) quantizes each weight to {-1, 0, 1}. Li & Liu (2016) and Zhu et al. (2017) added scaling to the ternarized weights, and DoReFa-Net (Zhou et al., 2016) further extended quantization to more than three levels. However, these methods do not consider the effect of quantization on the loss, and rely on heuristics in their procedures (Zhou et al., 2016; Zhu et al., 2017) . Recently, a loss-aware low-bit quantized neural network is proposed in (Leng et al., 2017) . However, it uses full-precision weights in the forward pass and the extra-gradient method (Vasilyev et al., 2010) for update, both of which are expensive.

In this paper, we propose an efficient and disciplined ternarization scheme for network compression. Inspired by (Hou et al., 2017) , we explicitly consider the effect of ternarization on the loss. This is formulated as an optimization problem which is then solved efficiently by the proximal Newton algorithm. When the loss surface's curvature is ignored, the proposed method reduces to that of (Li & Liu, 2016) , and is also related to the projection step of (Leng et al., 2017) . Next, we extend it to (i) allow the use of different scaling parameters for the positive and negative weights; and (ii) the use of m bits (where m > 2) for weight quantization. Experiments on both feedforward and recurrent neural networks show that the proposed quantization scheme outperforms state-of-the-art algorithms.

Notations: For a vector x, √

x denotes the element-wise square root (i.e., [

√ x] i = √ x i ), |x| is the element-wise absolute value, x p = ( i |x i | p )

1 p is its p-norm, and Diag(x) returns a diagonal matrix with x on the diagonal. For two vectors x and y, x y denotes the element-wise multiplication and x y the element-wise division. Given a threshold ∆, I ∆ (x) returns a vector such that 

[I ∆ (x)] i = 1 if x i > ∆, -1 if x i < -∆,

(x)] i = 1 if x i > ∆, and 0 otherwise. Similarly, [I - ∆ (x)] i = -1 if x i < -∆

, and 0 otherwise. For a matrix X, vec(X) returns a vector by stacking all the columns of X, and diag(X) returns a vector whose entries are from the diagonal of X.

2. RELATED WORK:

Let the full-precision weights from all L layers be w = [w 1 , w 2 , . . . , w L ] , where w l = vec(W l ), and W l is the weight matrix at layer l. The corresponding quantized weights will be denoted ŵ = [ ŵ 1 , ŵ 2 , . . . , ŵ L ] .

2.1. WEIGHT BINARIZED NETWORKS:

In BinaryConnect (Courbariaux et al., 2015) , each element of w l is binarized to -1 or +1 by using the sign function: Binarize(w l ) = sign(w l ). In the Binary-Weight-Network (BWN) (Rastegari et al., 2016) , a scaling parameter is also included, i.e., Binarize(w l ) = α l b l , where α l > 0, b l ∈ {-1, +1} n l and n l is the number of weights in w l . By minimizing the difference between w l and α l b l , the optimal α l , b l have the simple form: α l = w l 1 /n l , and b l = sign(w l ).

Instead of simply finding the best binary approximation for the full-precision weight w t l at iteration t, the loss-aware binarized network (LAB) directly minimizes the loss w.r.t. the binarized weight α t l b t l (Hou et al., 2017) . Let d t-1 l be a vector containing the diagonal of an approximate Hessian of the loss. It can be shown that

α t l = d t-1 l w t l 1 / d t-1 l

1 and b t l = sign(w t l ).

2.2. WEIGHT TERNARIZED NETWORKS:

In a weight ternarized network, zero is used as an additional quantized value. In TernaryConnect (Lin et al., 2016b) , each weight value is clipped to [-1, 1] before quantization, and then a non-negative weight [w t l ] i is stochastically quantized to 1 with probability [w t l ] i (and 0 otherwise). When [w t l ] i is negative, it is quantized to -1 with probability -[w t l ] i , and 0 otherwise. In the ternary weight network (TWN) (Li & Liu, 2016) 

] i = α t l if [w t l ] i > ∆ t l , -α t l if [w t l ] i < -∆ t

l and 0 otherwise). To obtain ∆ t l and α t l , TWN minimizes the 2 -distance between the full-precision and ternarized weights, leading to

∆ t l = arg max ∆>0 1 I ∆ (w t l ) 1   i:|[w t l ]i|>∆ t l |[w t l ] i |   2 , α t l = 1 I ∆ t l (w t l ) 1 i:|[w t l ]i|>∆ t l |[w t l ] i |. (1)

However, ∆ t l in ( 1) is difficult to solve. Instead, TWN simply sets ∆ t l = 0.7 • E(|w t l |) in practice. In TWN, one scaling parameter (α t l ) is used for both the positive and negative weights at layer l. In the trained ternary quantization (TTQ) network (Zhu et al., 2017) , different scaling parameters (α t l and β t l ) are used. The weight w t l is thus quantized to ŵt

l = α t l I + ∆ t l (w t l ) + β t l I - ∆ t l (w t l ).

The scaling parameters are learned by gradient descent. As for ∆ t l , two heuristics are used. The first sets ∆ t l to a constant fraction of max(|w t l |), while the second sets ∆ t l such that at all layers are equally sparse.

2.3. WEIGHT QUANTIZED NETWORKS:

In a weight quantized network, m bits (where m ≥ 2) are used to represent each weight. Let Q be a set of (2k + 1) quantized values, where

k = 2 m-1 -1. The two popular choices of Q are -1, -k-1 k , . . . , -1 k , 0, 1 k , . . . , k-1 k , 1 (linear quantization), and -1, -1 2 , . . . , -1 2 k-1 , 0, 1 2 k-1 , . . . , 1 2 , 1 (logarithmic quantization)

. By limiting the quantized values to powers of two, logarithmic quantization is advantageous in that expensive floating-point operations can be replaced by cheaper bit-shift operations. When m = 2, both schemes reduce to

Q = {-1, 0, 1}.

In the DoReFa-Net (Zhou et al., 2016) , weight w t l is heuristically quantized to m-bit, with:1 1) x). Similar to loss-aware binarization (Hou et al., 2017) , Leng et al. (2017) proposed a loss-aware quantized network called low-bit neural network (LBNN). The alternating direction method of multipliers (ADMM) (Boyd et al., 2011) is used for optimization. At the tth iteration, the full-precision weight w t l is first updated by the method of extra-gradient (Vasilyev et al., 2010) :

[ ŵt l ] i = 2 • quantize m tanh([w t l ] i ) 2 max(| tanh([w t l ] i )|) + 1 2 -1 in {-1, -2 m -2 2 m -1 , . . . , -1 2 m -1 , 1 2 m -1 , . . . , 2 m -2 2 m -1 , 1}, where quantize m (x) = 1 2 m -1 round((2 m -

EQUATION

where L is the augmented Lagrangian in the ADMM formulation, and η t is the stepsize. Next, w t l is projected to the space of m-bit quantized weights so that ŵt l is of the form α l b l , where α l > 0, and b

l ∈ -1, -1 2 , . . . , -1 2 k-1 , 0, 1 2 k-1 , . . . , 1 2 , 1 .

3 LOSS-AWARE QUANTIZATION

3.1. TERNARIZATION USING PROXIMAL NEWTON ALGORITHM:

In weight ternarization, TWN simply finds the closest ternary approximation of the full precision weight at each iteration, while TTQ sets the ternarization threshold heuristically. Inspired by LAB (for binarization), we consider the loss explicitly during quantization and obtain the quantization thresholds and scaling parameter by solving an optimization problem.

As in TWN, the weight w l is ternarized as ŵl = α l b l , where α l > 0 and b l ∈ {-1, 0, 1} n l . Given a loss function , we formulate weight ternarization as the following optimization problem:

EQUATION

where Q is the set of desired quantized values. As in LAB, we will solve this using the proximal Newton method (Lee et al., 2014; Rakotomamonjy et al., 2016) . At iteration t, the objective is replaced by the second-order expansion

EQUATION

where H t-1 is an estimate of the Hessian of at ŵt-1 . We use the diagonal equilibration preconditioner (Dauphin et al., 2015) , which is robust in the presence of saddle points and also readily available in popular stochastic deep network optimizers such as Adam (Kingma & Ba, 2015) . Let D l be the approximate diagonal Hessian at layer l. We use D = Diag([diag(D 1 ) , . . . , diag(D L ) ] ) as an estimate of H. Substituting (4) into (3), we solve the following subproblem at the tth iteration:

min ŵt ∇ ( ŵt-1 ) ( ŵt -ŵt-1 ) + 1 2 ( ŵt -ŵt-1 ) D t-1 ( ŵt -ŵt-1 ) (5) s.t. ŵt l = α t l b t l , α t l > 0, b t l ∈ Q n l , l = 1, . . . , L.

Proposition 3.1 The objective in (5) can be rewritten as

EQUATION

)

where d t-1 l ≡ diag(D t-1 l

), and

EQUATION

Obviously, this objective can be minimized layer by layer. Each proximal Newton iteration thus consists of two steps: (i) Obtain w t l in (7) by gradient descent along ∇ l ( ŵt-1 ), which is preconditioned by the adaptive learning rate 1 d t-1 l so that the rescaled dimensions have similar curvatures; (ii) Quantize w t l to ŵt l by minimizing the scaled difference between ŵt l and w t l in (6). Intuitively, when the curvature is low ([d t-1 l ] i is small), the loss is not sensitive to the weight and ternarization error can be less penalized. When the loss surface is steep, ternarization has to be more accurate.

Though the constraint in ( 6) is more complicated than that in LAB, interestingly the following simple relationship can still be obtained for weight ternarization. ; whereas when α is fixed, b = I α/2 (w t l ).

Equivalently, b can be written as Π Q (w t l /α), where Π Q (•) projects each entry of the input argument to the nearest element in Q. Further discussions on how to solve for α t l will be presented in Sections 3.1.1 and 3.1.2. When the curvature is the same for all dimensions at layer l, the following Corollary shows that the solution above reduces that of TWN.

Corollary 3.1 When D t-1 l = λI, α t l reduces to the TWN solution in (1) with ∆ t l = α t l /2. In other words, TWN corresponds to using the proximal gradient algorithm, while the proposed method corresponds to using the proximal Newton algorithm with diagonal Hessian. In composite optimization, it is known that the proximal Newton algorithm is more efficient than the proximal gradient algorithm (Lee et al., 2014; Rakotomamonjy et al., 2016) . Moreover, note that the interesting relationship ∆ t l = α t l /2 is not observed in TWN, while TTQ completely neglects this relationship. In LBNN (Leng et al., 2017) , its projection step uses an objective which is similar to (6), but without using the curvature information. Besides, their w t l is updated with the extra-gradient in (2) , which doubles the number of forward, backward and update steps, and can be costly. Moreover, LBNN uses full-precision weights in the forward pass, while all other quantization methods including ours use quantized weights (which eliminates most of the multiplications and thus faster training).

When (i) is continuously differentiable with Lipschitz-continuous gradient (i.e., there exists β > 0 such that ∇ (u) -∇ (v) 2 ≤ β uv 2 for any u, v); (ii) is bounded from below; and (iii)

[d t l ] k > β ∀l, k, t,

it can be shown that the objective of (3) produced by the proximal Newton algorithm (with solution in Proposition 3.2) converges (Hou et al., 2017) . In practice, it is important to keep the full-precision weights during update (Courbariaux et al., 2015) . Hence, we replace (7) by

w t l ← w t-1 l -∇ l ( ŵt-1 ) d t-1 l

. The whole procedure, which is called Loss-Aware Ternarization (LAT), is shown in Algorithm 3 of Appendix B. It is similar to Algorithm 1 of LAB (Hou et al., 2017) , except that α t l and b t l are computed differently. In step 4, following (Li & Liu, 2016) , we first rescale input x t-1 l with α l , so that multiplications in dot products and convolutions become additions. Algorithm 3 can also be easily extended to ternarize weights in recurrent networks. Interested readers are referred to (Hou et al., 2017) for details.

3.1.1. EXACT SOLUTION OF α t l:

To simplify notations, we drop the superscripts and subscripts. From Proposition 3.2,

EQUATION

We now consider how to solve for α. First, we introduce some notations. Given a vector x = [x 1 , x 2 , . . . , x n ], and an indexing vector s ∈ R n whose entries are a permutation of {1, . . . , n}, perm s (x) returns the vector [x s1 , x s2 , . . . We sort elements of |w| in descending order, and let the vector containing the sorted indices be s. For example, if w = [1, 0, -2], then s = [3, 1, 2] . From (8),

EQUATION

where c = cum(perm s (|d w|)) cum(perm s (d)) 2, and j is the index such that

EQUATION

)

For simplicity of notations, let the dimensionality of w (and thus also of c) be n, and the operation find(condition(x)) returns all indices in x that satisfies the condition. It is easy to see that any j satisfying ( 10) is in

S ≡ find([perm s (|w|)] [1:(n-1)] -c [1:(n-1)] ) ([perm s (|w|)] [2:n] -c [1:n-1] ) < 0), where c [1:(n-1)

] is the subvector of c with elements in the index range 1 to n -1. The optimal α (= 2c j ) is then the one which yields the smallest objective in ( 6), which can be simplified by Proposition 3.3 below. The procedure is shown in Algorithm 1.

Proposition 3.3:

The optimal α t l of (6) equals 2 arg max cj :j∈S c 2 j • [cum(perm s (d t-1 l

))] j .

Algorithm 1 Exact solver of (6) 

3: c = cum(perm s (|d t-1 l w t l |)) cum(perm s (d t-1 l )) 2; 4: S = find(([perm s (|w t l |)] [1:(n-1)] -c [1:(n-1)] ) ([perm s (|w t l |)] [2:n] -c [1:n-1] ) < 0); 5: α t l = 2 arg max cj :j∈S c 2 j • [cum(perm s (d t-1 l

))] j ; 6: b t l = I α t l /2 (w t l ); 7: Output: ŵt l = α t l b t l .

3.1.2. APPROXIMATE SOLUTION OF α t l:

In case the sorting operation in step 2 is expensive, α t l and b t l can be obtained by alternating the iteration in Proposition 3.2 (Algorithm 2). Empirically, it converges very fast, usually in 5 iterations.

Algorithm 2 Approximate solver for (6). b = I α/2 (w t l ); 7: end while 8: Output: ŵt l = αb.

3.2. EXTENSION TO TERNARIZATION WITH TWO SCALING PARAMETERS:

As in TTQ (Zhu et al., 2017) , we can use different scaling parameters for the positive and negative weights in each layer. The optimization subproblem at the tth iteration then becomes:

min ŵt ∇ ( ŵt-1 ) ( ŵt -ŵt-1 ) + 1 2 ( ŵt -ŵt-1 ) D t-1 ( ŵt -ŵt-1 ) (11) s.t. ŵt l ∈ {-β t l , 0, α t l } n l , α t l > 0, β t l > 0, l = 1, . . . , L.

Proposition 3.4 The optimal ŵt l in ( 5) is of the form ŵt l = α t l p t l + β t l q t l , where α t l =

p t l d t-1 l w t l 1 p t l d t-1 l 1 , p t l = I + α t l /2 (w t l ), β t l = q t l d t-1 l w t l 1 q t l d t-1 l 1

, and q t l = I -

β t l /2 (w t l ).

The exact and approximate solutions for α t l and β t l can be obtained in a similar way as in Sections 3.1.1 and 3.1.2. Details are in Appendix C.

3.3. EXTENSION TO LOW-BIT QUANTIZATION:

For m-bit quantization, we simply change the set Q of desired quantized values in (3) to one with k = 2 m-1 -1 quantized values. The optimization still contains a gradient descent step with adaptive learning rates like LAT, and a quantization step which can be solved efficiently by alternating minimization of (α, b) (similar to the procedure in Algorithm 2) using the following Proposition. Proposition 3.5 Let the optimal ŵt l in (6) be of the form αb. For a fixed b, α

= b d t-1 l w t l 1 b d t-1 l 1 ; whereas when α is fixed, b = Π Q ( w t l α ), where Q = -1, -k-1 k , . . . , -1 k , 0, 1 k , . . . , k-1 k , 1 for linear quantization and Q = -1, -1 2 , . . . , -1 2 k-1 , 0, 1 2 k-1 , . . . , 1 2 , 1 for logarithmic quantization.

4. EXPERIMENTS:

In this section, we perform experiments on both feedforward and recurrent neural networks. The following methods are compared: (i) the original full-precision network; (ii) weight-binarized networks, including BinaryConnect (Courbariaux et al., 2015) , Binary-Weight-Network (BWN) (Rastegari et al., 2016) , and Loss-Aware Binarized network (LAB) (Hou et al., 2017) ; (iii) weightternarized networks, including Ternary Weight Networks (TWN) (Li & Liu, 2016) , Trained Ternary Quantization (TTQ)2 (Zhu et al., 2017) , the proposed Loss-Aware Ternarized network with exact solution (LATe), approximate solution (LATa), and with two scaling parameters (LAT2e and LAT2a);

(iv) m-bit-quantized networks (where m > 2), including DoReFa-Netm (Zhou et al., 2016) , the proposed loss-aware quantized network with linear quantization (LAQm(linear)), and logarithmic quantization (LAQm(log)). Since weight quantization can be viewed as a form of regularization (Courbariaux et al., 2015) , we do not use other regularizers such as dropout and weight decay.

4.1. FEEDFORWARD NETWORKS:

In this section, we perform experiments with the multilayer perceptron (on the MNIST data set) and convolutional neural networks (on CIFAR-10, CIFAR-100 and SVHN). For MNIST, CIFAR-10, and SVHN, the setup is similar to that in (Courbariaux et al., 2015; Hou et al., 2017) . Details can be found in Appendix D. For CIFAR-100, we use 45, 000 images for training, another 5, 000 for validation, and the remaining 10, 000 for testing. The testing errors are shown in Table 1 .

Ternarization: On MNIST, CIFAR100 and SVHN, the weight-ternarized networks perform better than weight-binarized networks, and are comparable to the full-precision networks. Among the weight-ternarized networks, the proposed LAT and its variants have the lowest errors. On CIFAR-10, LATa has similar performance as the full-precision network, but is outperformed by BinaryConnect. first and last layers (conv1 and linear3, respectively) are larger than the others. This agrees with the finding that, to maintain the activation variance and back-propagated gradients variance during the forward and backward propagations, the variance of the weights between the lth and (l + 1)th layers should roughly follow 2/(n l +n l+1 ) (Glorot & Bengio, 2010) . Hence, as the input and output layers are small, larger scaling parameters are needed for their high-variance weights. Using Two Scaling Parameters: Compared to TTQ, the proposed LAT2 always has better performance. However, the extra flexibility of using two scaling parameters does not always translate to lower testing error. As can be seen, it outperforms algorithms with one scaling parameter only on CIFAR-100. We speculate this is because the capacities of deep networks are often larger than needed, and so the limited expressiveness of quantized weights may not significantly deteriorate performance. Indeed, as pointed out in (Courbariaux et al., 2015) , weight quantization is a form of regularization, and can contribute positively to the performance.

Using More Bits: Among the 3-bit quantization algorithms, the proposed scheme with logarithmic quantization has the best performance. It also outperforms the other quantization algorithms on CIFAR-100 and SVHN. However, as discussed above, more quantization flexibility is useful only when the weight-quantized network does not have enough capacity.

4.2. RECURRENT NETWORKS:

In this section, we follow (Hou et al., 2017) and perform character-level language modeling experiments on the long short-term memory (LSTM) (Hochreiter & Schmidhuber, 1997) . The training objective is the cross-entropy loss over all target sequences. Experiments are performed on three Published as a conference paper at ICLR 2018 data sets: (i) Leo Tolstoy's War and Peace; (ii) source code of the Linux Kernel; and (iii) Penn Treebank Corpus (Taylor et al., 2003) . For the first two, we follow the setting in (Karpathy et al., 2016; Hou et al., 2017) . For Penn Treebank, we follow the setting in (Mikolov & Zweig, 2012) . In the experiment, we tried different initializations for TTQ and then report the best. Cross-entropy values on the test set are shown in Table 2 . Ternarization: As in Section 4.1, the proposed LATe and LATa outperform the other weight ternarization schemes, and are even better than the full-precision network on all three data sets. Figure 2 shows convergence of the training and validation losses on War and Peace. Among the ternarization methods, LAT and its variants converge faster than both TWN and TTQ. Using Two Scaling Parameters: LAT2e and LAT2a outperform TTQ on all three data sets. They also perform better than using one scaling parameter on War and Peace and Penn Treebank.

Using More Bits: The proposed LAQ always outperforms DoReFa-Net when 3 or 4 bits are used.

As noted in Section 4.1, using more bits does not necessarily yield better generalization performance, and ternarization (using 2 bits) yields the lowest validation loss on War and Peace and Linux Kernel. Moreover, logarithmic quantization is better than linear quantization. Figure 3 shows distributions of the input-to-hidden (full-precision and quantized) weights of the input gate trained after 20 epochs using LAQ3(linear) and LAQ3(log) (results on the other weights are similar). As can be seen, distributions of the full-precision weights are bell-shaped. Hence, logarithmic quantization can give finer resolutions to many of the weights which have small magnitudes. Quantized vs Full-precision Networks: The quantized networks often perform better than the fullprecision networks. We speculate that this is because deep networks often have larger-than-needed capacities, and so are less affected by the limited expressiveness of quantized weights. Moreover, low-bit quantization acts as regularization, and so contributes positively to the performance.

5. CONCLUSION:

In this paper, we proposed a loss-aware weight quantization algorithm that directly considers the effect of quantization on the loss. The problem is solved using the proximal Newton algorithm. Each iteration consists of a preconditioned gradient descent step and a quantization step that projects fullprecision weights onto a set of quantized values. For ternarization, an exact and an efficient approximate solution are provided. The procedure is also extended to the use of different scaling parameters for the positive and negative weights, and to m-bit (where m > 2) quantization. Experiments on both feedforward and recurrent networks show that the proposed quantization scheme outperforms the current state-of-the-art.

∆ t l = 1 2

I α t l /2 w t l 1 I α t l /2 1 = arg max ∆>0 1 I ∆ (w t l ) 1   i:[w t l ]i>∆ |[w t l ] i |   2 .

This is the same as the TWN solution in (1) .

A.4 PROOF OF PROPOSITION 3.3 For simplicity of notations, we drop the subscript and superscript. For each layer, we have an optimization problem of the form arg min A.5 PROOF FOR PROPOSITION 3.4 For simplicity of notations, we drop the subscript and superscript, and consider the optimization problem:

min α,b 1 2 n i=1 d i ( ŵi -w i ) 2 s.t.

ŵi ∈ {-β, 0, +α}. Let f ( ŵi ) = ( ŵi -w i ) 2 . Then, f (α) = (α -w i ) 2 , f (0) = w 2 i , and f (-β) = (β + w i ) 2 . It is easy to see that (i) if w i > α/2, f (α) is the smallest; (ii) if w i < -β/2, f (-1) is the smallest; (iii) if -β/2 ≤ w i ≤ α/2, f (0) is the smallest. In other words, the optimal ŵi satisfies ŵi = αI + α/2 (w i ) + βI - β/2 (w i ), or equivalently, ŵ = αp + βq, where p = I + α/2 (w), and q = I - β (w).

Define w + and w -such that [w + ] i = w i w i > 0 0 otherwise, and [w -] i = w i w i < 0 0 otherwise. . Then,

EQUATION

)

The objective in (12) has two parts, and each part can be viewed as a special case of the ternarization step in Proposition 3.1 (considering only with positive or negative weights). Similar to the proof for Proposition 3.2, we can obtain that the optimal ŵ = αp + βq satisfies α = p d w 1 p d 1 , p = I + α/2 (w), β = q d w 1 q d 1 , q = I - β/2 (w).

:

Note that the quantized value of 0 is not used in DoReFa-Net.

For TTQ, we follow the CIFAR-10 setting in(Zhu et al., 2017), and set ∆ t l = 0.005 max(|w t l |).

Figures and Tables:

With Q = {-1, 0, 1}, and the optimal ŵt l in (6) of the form αb. For a fixed b,

x sn ], and cum(x) = [x 1 , 2 i=1 x i , . . . , n i=1 x i ] returns partial sums for elements in x. For example, let a = [1, -1, -2], and b = [3, 1, 2]. Then, perm b (a) = [-2, 1, -1] and cum(a) = [1, 0, -2].

Input: b t-1 l , full-precision weight w t l , diagonal entries of the approximate Hessian d t-1 l Initialize: α = 1.0, α old = 0.0, b = b t-1 l , = 10 -6 ; 3: while |α -α old | > do

Figure 1(a) shows convergence of the training loss for LATa on CIFAR-10, and Figure 1(b) shows the scaling parameter obtained at each CNN layer. As can be seen, the scaling parameters for the

(a) Training loss. (b) Scaling parameter α.

Figure 1: Convergence of the training loss and scaling parameter by LATa on CIFAR-10.

Figure 2: Convergence of the training and validation losses on War and Peace.

(a) Full-precision weights. (b) Quantized weights. (c) Full-precision weights. (d) Quantized weights.

Figure 3: Distributions of the full-precision and LAQ3-quantized weights on War and Peace. Left ((a) and (b)): Linear quantization; Right ((c) and (d)): Logarithmic quantization.

2 (w) I α/2 (w) d 1 α -I α/2 (w) d w 1 I α/2 (w) I α/2 (w) d 1 I α/2 (w) I α/2 (w) w 2 α/2 (w) I α/2 (w) d 1 = arg min α -I α/2 (w) d w 2 α/2 (w) d 1 ,where the second equality holds as b = I α/2 (w). From (9), we have-I α/2 (w) d w 2 α/2 (w) d 1 = -I α/2 (w) d w 1 I α/2 (w) d 1 • I α/2 (w) d w 1 I α/2 (w) d 1 • I α/2 (w) d -2c j • 2c j • [cum(perm s (d))] j = -2c 2 j • [cum(perm s (d))] j .Thus, the α that minimizes ( √ d (αb -w)) 2 is α = 2 arg max cj ,j∈S c 2 j • [cum(perm s (d))] j .

and 0 otherwise. I + ∆ (x) considers only the positive threshold, i.e., [I + ∆

Table content: <table/>

Testing errors (%) on the feedforward networks. Algorithm with the lowest error in each group is highlighted.

Table content: <table><tr><td>MNIST CIFAR-10 CIFAR-100 SVHN</td></tr></table>

Testing cross-entropy values on the LSTM. Algorithm with the lowest cross-entropy value in each group is highlighted.

Table content: <table><tr><td>War and Peace Linux Kernel Penn Treebank</td></tr></table>

Peer review (iclr2018):
 This paper extends the loss-aware weight binarization scheme to ternarization and arbitrary m-bit quantization and demonstrate its promising performance in the experiments. Review: Pros This paper formulates the weight quantization of deep networks as an optimization problem in the perspective of loss and solves the problem with a proximal newton algorithm. They extend the scheme to allow the use of different scaling parameters and to m-bit quantization. Experiments demonstrate the proposed scheme outperforms the state-of-the-art methods. The experiments are complete and the writing is good. Cons Although the work seems convincing, it is a little bit straight-forward derived from the original binarization scheme (Hou et al., 2017) to tenarization or m-bit since there are some analogous extension ideas (Lin et al., 2016b, Li & Liu, 2016b). Algorithm 2 and section 3.2 and 3.3 can be seen as additive complementary.