Bi-Real Net: Enhancing the Performance of 1-bit CNNs With Improved Representational Capability and Advanced Training Algorithm

Zechun Liu, Baoyuan Wu, Wenhan Luo, Xin Yang, Wei Liu, Kwang-Ting Cheng

Introduction

Deep Convolutional Neural Networks (CNNs) have achieved substantial advances in a wide range of vision tasks, such as object detection and recognition , depth perception , visual relation detection , face tracking and alignment , object tracking , etc. However, the superior performance of CNNs usually requires powerful hardware with abundant computing and memory resources. For example, high-end Graphics Processing Units (GPUs). Meanwhile, there are growing demands to run vision tasks, such as augmented reality and intelligent navigation, on mobile hand-held devices and small drones. Most mobile devices are not equipped with a powerful GPU neither an adequate amount of memory to run and store the expensive CNN model. Consequently, the high demand for computation and memory becomes the bottleneck of deploying the powerful CNNs on most mobile devices. In general, there are three major approaches to alleviate this limitation. The first is to reduce the number of weights, such as Sparse CNN . The second is to quantize the weights (e.g., QNN and DoReFa Net ). The third is to quantize both weights and activations, with the extreme case of both weights and activations being binary.

In this work, we study the extreme case of the third approach, i.e., the binary CNNs. It is also called 1-bit CNNs, as each weight parameter and activation can be represented by 1-bit. As demonstrated in , up to 32×32\times memory saving and 58×58\times speedup on CPUs have been achieved for a 1-bit convolution layer, in which the computationally heavy matrix multiplication operations become light-weighted bitwise XNOR operations and bit-count operations. The current binarization method achieves comparable accuracy to real-valued networks on small datasets (e.g., CIFAR-10 and MNIST). However on the large-scale datasets (e.g., ImageNet), the binarization method based on AlexNet in encounters severe accuracy degradation, i.e., from 56.6%56.6\% to 27.9%27.9\% . It reveals that the capability of conventional 1-bit CNNs is not sufficient to cover great diversity in large-scale datasets like ImageNet. Another binary network called XNOR-Net was proposed to enhance the performance of 1-bit CNNs, by utilizing the absolute mean of weights and activations.

The objective of this study is to further improve 1-bit CNNs, as we believe its potential has not been fully explored. One important observation is that during the inference process, 1-bit convolution layer generates integer outputs, due to the bit-count operations. The integer outputs will become real values if there is a BatchNorm layer. But these real-valued activations are then binarized to −1-1 or +1+1 through the consecutive sign function, as shown in Fig. 1(a). Obviously, compared to binary activations, these integers or real activations contain more information, which is lost in the conventional 1-bit CNNs . Inspired by this observation, we propose to keep these real activations via adding a simple yet effective shortcut, dubbed Bi-Real net. As shown in Fig. 1(b), the shortcut connects the real activations to an addition operator with the real-valued activations of the next block. By doing so, the representational capability of the proposed model is much higher than that of the original 1-bit CNNs, with only a negligible computational cost incurred by the extra element-wise addition and without any additional memory cost.

Moreover, we further propose a novel training algorithm for 1-bit CNNs including three technical novelties:

Approximation to the derivative of the sign function with respect to activations. As the sign function binarizing the activation is non-differentiable, we propose to approximate its derivative by a piecewise linear function in the backward pass, derived from the piecewise polynomial function that is a second-order approximation of the sign function. In contrast, the approximated derivative using a step function (i.e., 1∣x∣<11_{|x|<1}) proposed in is derived from the clip function (i.e., clip(-1,x,1)), which is also an approximation to the sign function. We show that the piecewise polynomial function is a closer approximation to the sign function than the clip function. Hence, its derivative is more effective than the derivative of the clip function.

Magnitude-aware gradient with respect to weights. As the gradient of loss with respect to the binary weight is not large enough to change the sign of the binary weight, the binary weight cannot be directly updated using the standard gradient descent algorithm. In BinaryNet , the real-valued weight is first updated using gradient descent, and the new binary weight is then obtained through taking the sign of the updated real weight. However, we find that the gradient with respect to the real weight is only related to the sign of the current real weight, while independent of its magnitude. To derive a more effective gradient, we propose to use a magnitude-aware sign function during training, then the gradient with respect to the real weight depends on both the sign and the magnitude of the current real weight. After convergence, the binary weight (i.e., -1 or +1) is obtained through the sign function of the final real weight for inference.

Initialization. As a highly non-convex optimization problem, the training of 1-bit CNNs is likely to be sensitive to initialization. In , the 1-bit CNN model is initialized using the real-valued CNN model with the ReLU function pre-trained on ImageNet. We propose to replace ReLU by the clip function in pre-training, as the activation of the clip function is closer to the binary activation than that of ReLU.

Experiments on ImageNet show that the above three ideas are useful to train 1-bit CNNs, including both Bi-Real net and other network structures. Specifically, their respective contributions to the improvements of top-1 accuracy are up to 12%, 23% and 13% for a 18-layer Bi-Real net. With the dedicatedly-designed shortcut and the proposed optimization techniques, our Bi-Real net, with only binary weights and activations inside each 1-bit convolution layer, achieves 56.4% and 62.2% top-1 accuracy with 18-layer and 34-layer structures, respectively, with up to 16.0×\times memory saving and 19.0×\times computational cost reduction compared to the full-precision CNN. Comparing to the state-of-the-art model (e.g., XNOR-Net), Bi-Real net achieves 10% higher top-1 accuracy on the 18-layer network.

Related Work

Reducing the number of parameters. Several methods have been proposed to compress neural networks by reducing the number of parameters and neural connections. For instance, He et al. proposed a bottleneck structure which consists of three convolution layers of filter size 1×\times1, 3×\times3 and 1×\times1 with a shortcut connection as a preliminary building block to reduce the number of parameters and to speed up training. In SqueezeNet , some 3×\times3 convolutions are replaced with 1×\times1 convolutions, resulting in a 50×\times reduction in the number of parameters. FitNets imitates the soft output of a large teacher network using a thin and deep student network, and in turn yields 10.4×\times fewer parameters and similar accuracy to a large teacher network on the CIFAR-10 dataset. In Sparse CNN , a sparse matrix multiplication operation is employed to zero out more than 90% of parameters to accelerate the learning process. Motivated by the Sparse CNN, Han et al. proposed Deep Compression which employs connection pruning, quantization with retraining and Huffman coding to reduce the number of neural connections, thus, in turn, reduces the memory usage.

Parameter quantization. The previous study demonstrated that real-valued deep neural networks such as AlexNet , GoogLeNet and VGG-16 only encounter marginal accuracy degradation when quantizing 32-bit parameters to 8-bit. In Incremental Network Quantization, Zhou et al. quantize the parameter incrementally and show that it is even possible to further reduce the weight precision to 2-5 bits with slightly higher accuracy than a full-precision network on the ImageNet dataset. In BinaryConnect , Courbariaux et al. employ 1-bit precision weights (1 and -1) while maintaining sufficiently high accuracy on the MNIST, CIFAR10 and SVHN datasets.

Quantizing weights properly can achieve considerable memory savings with little accuracy degradation. However, acceleration via weight quantization is limited due to the real-valued activations (i.e., the input to convolution layers).

Several recent studies have been conducted to explore new network structures and/or training techniques for quantizing both weights and activations while minimizing accuracy degradation. Successful attempts include DoReFa-Net and QNN , which explore neural networks trained with 1-bit weights and 2-bit activations, and the accuracy drops by 6.1% and 4.9% respectively on the ImageNet dataset compared to the real-valued AlexNet. Additionally, BinaryNet uses only 1-bit weights and 1-bit activations in a neural network and achieves comparable accuracy as full-precision neural networks on the MNIST and CIFAR-10 datasets. In XNOR-Net , Rastegari et al. further improve BinaryNet by multiplying the absolute mean of the weight filter and activation with the 1-bit weight and activation to improve the accuracy. ABC-Net proposes to enhance the accuracy by using more weight bases and activation bases. The results of these studies are encouraging, but admittedly, due to the loss of precision in weights and activations, the number of filters in the network (thus the algorithm complexity) grows in order to maintain high accuracy, which offsets the memory saving and speedup of binarizing the network.

In this study, we aim to design 1-bit CNNs aided with a real-valued shortcut to compensate for the accuracy loss of binarization. Optimization strategies for overcoming the gradient dismatch problem and discrete optimization difficulties in 1-bit CNNs, along with a customized initialization method, are proposed to fully explore the potential of 1-bit CNNs with its limited resolution.

Methodology

1-bit convolutional neural networks (CNNs) refer to the CNN models with binary weight parameters and binary activations in intermediate convolution layers. Specifically, the binary activation and weight are obtained through a sign function,

where ara_{r} and wrw_{r} indicate the real activation and the real weight, respectively. ara_{r} exists in both training and inference process of the 1-bit CNN, due to the convolution and batch normalization (if used). As shown in Fig. 2, given a binary activation map and a binary 3×33\times 3 weight kernel, the output activation could be any odd integer from −9-9 to 99. If a batch normalization is followed, as shown in Fig. 3, then the integer activation will be transformed into real values. The real weight will be used to update the binary weights in the training process, which will be introduced later.

Compared to the real-valued CNN model with the 32-bit weight parameter, the 1-bit CNNs obtains up to 32×32\times memory saving. Moreover, as the activation is also binary, then the convolution operation could be implemented by the bitwise XNOR operation and a bit-count operation. One simple example of the bitwise operation is shown in Fig. 2. In contrast, the convolution operation in real-valued CNNs is implemented by the expensive real value multiplication. Consequently, the 1-bit CNNs could obtain up to 64×\times computation saving.

2 Bi-Real Net Model and Its Representational Capability

We propose to preserve the real activations before the sign function to increase the representational capability of the 1-bit CNN, through a simple shortcut. Specifically, as shown in Fig. 3(b), one block indicates the structure that “Sign →\rightarrow 1-bit convolution →\rightarrow batch normalization →\rightarrow addition operator”. The shortcut connects the input activations to the sign function in the current block to the output activations after the batch normalization in the same block, and these two activations are added through an addition operator, and then the combined activations are inputted to the sign function in the next block. The representational capability of each entry in the added activations is 2892289^{2}. Consequently, the representational capability of each block in the 1-bit CNN with the above shortcut becomes (2892)6272(289^{2})^{6272}. As both real and binary activations are kept, we call the proposed model as Bi-Real net.

The representational capability of each block in the 1-bit CNN is significantly enhanced due to the simple identity shortcut. The only additional cost of computation is the addition operation of two real activations, as these real activations already exist in the standard 1-bit CNN (i.e., without shortcuts). Moreover, as the activations are computed on the fly, no additional memory is needed.

3 Training Bi-Real Net

As both activations and weight parameters are binary, the continuous optimization method, i.e., the stochastic gradient descent(SGD), cannot be directly adopted to train the 1-bit CNN. There are two major challenges. One is how to compute the gradient of the sign function on activations, which is non-differentiable. The other is that the gradient of the loss with respect to the binary weight is too small to change the weight’s sign. The authors of proposed to adjust the standard SGD algorithm to approximately train the 1-bit CNN. Specifically, the gradient of the sign function on activations is approximated by the gradient of the piecewise linear function, as shown in Fig. 5(b). To tackle the second challenge, the method proposed in updates the real-valued weights by the gradient computed with regard to the binary weight and obtains the binary weight by taking the sign of the real weights. As the identity shortcut will not add difficulty for training, the training algorithm proposed in can also be adopted to train the Bi-Real net model. However, we propose a novel training algorithm to tackle the above two major challenges, which is more suitable for the Bi-Real net model as well as other 1-bit CNNs. Besides, we also propose a novel initialization method.

We present a graphical illustration of the training of Bi-Real net in Fig. 4. The identity shortcut is omitted in the graph for clarity, as it will not change the main part of the training algorithm.

As shown in Fig. 5(a), the derivative of the sign function is an impulse function, which cannot be utilized in training.

where F(Arl,t)F(\mathbf{A}_{r}^{l,t}) is a differentiable approximation of the non-differentiable Sign(Arl,t)Sign(\mathbf{A}_{r}^{l,t}). In , F(Arl,t)F(\mathbf{A}_{r}^{l,t}) is set as the clip function, leading to the derivative as a step-function (see 5(b)). In this work, we utilize a piecewise polynomial function (see 5(c)) as the approximation function, as Eq. (14) left.

As shown Fig. 5, the shaded areas with blue slashes can reflect the difference between the sign function and its approximation. The shaded area corresponding to the clip function is 11, while that corresponding to Eq. (14) left is 23\frac{2}{3}. We conclude that Eq. (14) left is a closer approximation to the sign function than the clip function. Consequently, the derivative of Eq. (14) left is formulated as Eq. (14) right, which is a piecewise linear function.

3.2 Magnitude-aware gradient with respect to weights.

Here we present how to update the binary weight parameter in the lthl^{th} block, i.e., Wbl∈{−1,+1}\mathbf{W}_{b}^{l}\in\{-1,+1\}. For clarity, we assume that there is only one weight kernel, i.e., Wbl\mathbf{W}_{b}^{l} is a matrix.

The standard gradient descent algorithm cannot be directly applied as the gradient is not large enough to change the binary weights. To tackle this problem, the method of introduced a real weight Wrl\mathbf{W}_{r}^{l} and a sign function during training. Hence the binary weight parameter can be seen as the output to the sign function, i.e., Wbl=Sign(Wrl)\mathbf{W}_{b}^{l}=Sign(\mathbf{W}_{r}^{l}), as shown in the upper sub-figure in Fig. 4. Consequently, Wrl\mathbf{W}_{r}^{l} is updated using gradient descent in the backward pass, as follows

Note that ∂Wbl,t∂Wrl,t\frac{\partial\mathbf{W}_{b}^{l,t}}{\partial\mathbf{W}_{r}^{l,t}} indicates the element-wise derivative. In , ∂Wbl,t(i,j)∂Wrl,t(i,j)\frac{\partial\mathbf{W}_{b}^{l,t}(i,j)}{\partial\mathbf{W}_{r}^{l,t}(i,j)} is set to 11 if Wrl,t(i,j)∈\mathbf{W}_{r}^{l,t}(i,j)\in, otherwise . The derivative ∂L∂Wbl,t\frac{\partial\mathcal{L}}{\partial\mathbf{W}_{b}^{l,t}} is derived from the chain rule, as follows

where θl,t=∂Arl+1,t∂Aml,t\theta^{l,t}=\frac{\partial\mathbf{A}_{r}^{l+1,t}}{\partial\mathbf{A}_{m}^{l,t}} denotes the derivative of the BatchNorm layer (see Fig. 4) and has a negative correlation to Wbl,t\mathbf{W}_{b}^{l,t} . As Wbl,t∈{−1,+1}\mathbf{W}_{b}^{l,t}\in\{-1,+1\}, the gradient ∂L∂Wrl,t\frac{\partial\mathcal{L}}{\partial\mathbf{W}_{r}^{l,t}} is only related to the sign of Wrl,t\mathbf{W}_{r}^{l,t}, while is independent of its magnitude.

Based on this observation, we propose to replace the above sign function by a magnitude-aware function, as follows:

where ∣Wrl,t∣|\mathbf{W}_{r}^{l,t}| denotes the number of entries in Wrl,t\mathbf{W}_{r}^{l,t}. Consequently, the update of Wrl\mathbf{W}_{r}^{l} becomes

where ∂W‾bl,t∂Wrl,t≈∥Wrl,t∥1,1∣Wrl,t∣⋅∂Sign(Wrl,t)∂Wrl,t≈1∣Wrl,t∣<1\frac{\partial\overline{\mathbf{W}}_{b}^{l,t}}{\partial\mathbf{W}_{r}^{l,t}}\approx\frac{\parallel\mathbf{W}_{r}^{l,t}\parallel_{1,1}}{|\mathbf{W}_{r}^{l,t}|}\cdot\frac{\partial Sign(\mathbf{W}_{r}^{l,t})}{\partial\mathbf{W}_{r}^{l,t}}\approx\mathbf{1}_{|\mathbf{W}_{r}^{l,t}|<1} and θ‾l,t\overline{\theta}^{l,t} is associated with the magnitude of Wrl,t\mathbf{W}_{r}^{l,t}. Thus, the gradient ∂L∂Wrl,t\frac{\partial\mathcal{L}}{\partial\mathbf{W}_{r}^{l,t}} is related to both the sign and magnitude of Wrl,t\mathbf{W}_{r}^{l,t}. After training for convergence, we still use Sign(Wrl)Sign(\mathbf{W}_{r}^{l}) to obtain the binary weight Wbl\mathbf{W}_{b}^{l} (i.e., -1 or +1), and use θl\theta^{l} to absorb ∥Wrl∥1,1∣Wrl∣\frac{\parallel\mathbf{W}_{r}^{l}\parallel_{1,1}}{|\mathbf{W}_{r}^{l}|} and to associate with the magnitude of Wbl\mathbf{W}_{b}^{l} used for inference.

3.3 Initialization.

In , the initial weights of the 1-bit CNNs are derived from the corresponding real-valued CNN model pre-trained on ImageNet. However, the activation of ReLU is non-negative, while that of Sign is −1-1 or +1+1. Due to this difference, the real CNNs with ReLU may not provide a suitable initial point for training the 1-bit CNNs. Instead, we propose to replace ReLU with clip(−1,x,1)\text{clip}(-1,x,1) to pre-train the real-valued CNN model, as the activation of the clip function is closer to the sign function than ReLU. The efficacy of this new initialization will be evaluated in experiments.

Experiments

In this section, we firstly introduce the dataset for experiments and implementation details in Sec 4.1. Then we conduct ablation study in Sec. 4.2 to investigate the effectiveness of the proposed techniques. This part is followed by comparing our Bi-Real net with other state-of-the-art binary networks regarding accuracy in Sec 4.3. Sec. 4.4 reports memory usage and computation cost in comparison with other networks.

The experiments are carried out on the ILSVRC12 ImageNet classification dataset . ImageNet is a large-scale dataset with 1000 classes and 1.2 million training images and 50k validation images. Compared to other datasets like CIFAR-10 or MNIST , ImageNet is more challenging due to its large scale and great diversity. The study on this dataset will validate the superiority of the proposed Bi-Real network structure and the effectiveness of three training methods for 1-bit CNNs. In our comparison, we report both the top-1 and top-5 accuracies.

For each image in the ImageNet dataset, the smaller dimension of the image is rescaled to 256 while keeping the aspect ratio intact. For training, a random crop of size 224 ×\times 224 is selected. Note that, in contrast to XNOR-Net and the full-precision ResNet, we do not use the operation of random resize, which might improve the performance further. For inference, we employ the 224 ×\times 224 center crop from images.

Training: We train two instances of the Bi-Real net, including an 18-layer Bi-Real net and a 34-layer Bi-Real net. The training of them consists of two steps: training the 1-bit convolution layer and retraining the BatchNorm. In the first step, the weights in the 1-bit convolution layer are binarized to the sign of real-valued weights multiplying the absolute mean of each kernel. We use the SGD solver with the momentum of 0.9 and set the weight-decay to 0, which means we no longer encourage the weights to be close to 0. For the 18-layer Bi-Real net, we run the training algorithm for 20 epochs with a batch size of 128. The learning rate starts from 0.01 and is decayed twice by multiplying 0.1 at the 10th and the 15th epoch. For the 34-layer Bi-Real net, the training process includes 40 epochs and the batch size is set to 1024. The learning rate starts from 0.08 and is multiplied by 0.1 at the 20th and the 30th epoch, respectively. In the second step, we constraint the weights to -1 and 1, and set the learning rate in all convolution layers to 0 and retrain the BatchNorm layer for 1 epoch to absorb the scaling factor.

Inference: we use the trained model with binary weights and binary activations in the 1-bit convolution layers for inference.

2 Ablation Study

Three building blocks. The shortcut in our Bi-Real net transfers real-valued representation without additional memory cost, which plays an important role in improving its capability. To verify its importance, we implemented a Plain-Net structure without shortcut as shown in Fig. 6 (d) for comparison. At the same time, as our network structure employs the same number of weight filters and layers as the standard ResNet, we also make a comparison with the standard ResNet shown in Fig. 6 (c). For a fair comparison, we adopt the ReLU-only pre-activation ResNet structure in , which differs from Bi-Real net only in the structure of two layers per block instead of one layer per block. The layer order and shortcut design in Fig. 6 (c) are also applicable for 1-bit CNN. The comparison can justify the benefit of implementing our Bi-Real net by specifically replacing the 2-conv-layer-per-block Res-Net structure with two 1-conv-layer-per-block Bi-Real structure.

As discussed in Sec. 3, we proposed to overcome the optimization challenges induced by discrete weights and activations by 1) approximation to the derivative of the sign function with respect to activations, 2) magnitude-aware gradient with respect to weights and 3) clip initialization. To study how these proposals benefit the 1-bit CNNs individually and collectively, we train the 18-layer structure and the 34-layer structure with a combination of these techniques on the ImageNet dataset. Thus we derive 2×3×2×2×2=482\times 3\times 2\times 2\times 2=48 pairs of values of top-1 and top-5 accuracy, which are presented in Table 1.

Based on Table 1, we can evaluate each technique’s individual contribution and collective contribution of each unique combination of these techniques towards the final accuracy.

1) Comparing the 4th−7th4^{\textit{th}}-7^{\textit{th}} columns with the 8th−9th8^{\textit{th}}-9^{\textit{th}} columns, both the proposed Bi-Real net and the binarized standard ResNet outperform their plain counterparts with a significant margin, which validates the effectiveness of shortcut and the disadvantage of directly concatenating the 1-bit convolution layers. As Plain-18 has a thin and deep structure, which has the same weight filters but no shortcut, binarizing it results in very limited network representational capacity in the last convolution layer, and thus can hardly achieve good accuracy.

2) Comparing the 4th−5th4^{\textit{th}}-5^{\textit{th}} and 6th−7th6^{\textit{th}}-7^{\textit{th}} columns, the 18-layer Bi-Real net structure improves the accuracy of the binarized standard ResNet-18 by about 18%. This validates the conjecture that the Bi-Real net structure with more shortcuts further enhances the network capacity compared to the standard ResNet structure. Replacing the 2-conv-layer-per-block structure employed in Res-Net with two 1-conv-layer-per-block structure, adopted by Bi-Real net, could even benefit a real-valued network.

3) All proposed techniques for initialization, weight update and activation backward improve the accuracy at various degrees. For the 18-layer Bi-Real net structure, the improvement from the weight (about 23%, by comparing the 2nd2^{\textit{nd}} and 4th4^{\textit{th}} rows) is greater than the improvement from the activation (about 12%, by comparing the 2nd2^{\textit{nd}} and 3rd3^{\textit{rd}} rows) and the improvement from replacing ReLU with Clip for initialization (about 13%, by comparing the 2nd2^{\textit{nd}} and 7th7^{\textit{th}} rows). These three proposed training mechanisms are independent and can function collaboratively towards enhancing the final accuracy.

4) The proposed training methods can improve the final accuracy for all three networks in comparison with the original training method, which implies these proposed three training methods are universally suitable for various networks.

5) The two implemented Bi-Real nets (i.e. the 18-layer and 34-layer structures) together with the proposed training methods, achieve approximately 83% and 89% of the accuracy level of their corresponding full-precision networks, but with a huge amount of speedup and computation cost saving.

In short, the shortcut enhances the network representational capability, and the proposed training methods help the network to approach the accuracy upper bound.

3 Accuracy Comparison With State-of-The-Art

While the ablation study demonstrates the effectiveness of our 1-layer-per-block structure and the proposed techniques for optimal training, it is also necessary to compare with other state-of-the-art methods to evaluate Bi-Real net’s overall performance. To this end, we carry out a comparative study with three methods: BinaryNet , XNOR-Net and ABC-Net . These three networks are representative methods of binarizing both weights and activations for CNNs and achieve the state-of-the-art results. Note that, for a fair comparison, our Bi-Real net contains the same amount of weight filters as the corresponding ResNet that these methods attempt to binarize, differing only in the shortcut design.

Table 2 shows the results. The results of the three networks are quoted directly from the corresponding references, except that the result of BinaryNet is quoted from ABC-Net . The comparison clearly indicates that the proposed Bi-Real net outperforms the three networks by a considerable margin in terms of both the top-1 and top-5 accuracies. Specifically, the 18-layer Bi-Real net outperforms its 18-layer counterparts BinaryNet and ABC-Net with relative 33% advantage, and achieves a roughly 10% relative improvement over the XNOR-Net. Similar improvements can be observed for 34-layer Bi-Real net. In short, our Bi-Real net is more competitive than the state-of-the-art binary networks.

4 Efficiency and Memory Usage Analysis

In this section, we analyze the saving of memory usage and speedup in computation of Bi-Real net by comparing with the XNOR-Net and the full-precision network individually.

The memory usage is computed as the summation of 32 bit times the number of real-valued parameters and 1 bit times the number of binary parameters in the network. For efficiency comparison, we use FLOPs to measure the total real-valued multiplication computation in the Bi-Real net, following the calculation method in . As the bitwise XNOR operation and bit-counting can be performed in a parallel of 64 by the current generation of CPUs, the FLOPs is calculated as the amount of real-valued floating point multiplication plus 1/64 of the amount of 1-bit multiplication.

We follow the suggestion in XNOR-Net , to keep the weights and activations in the first convolution and the last fully-connected layers to be real-valued. We also adopt the same real-valued 1x1 convolution in Type B short-cut as implemented in XNOR-Net. Note that this 1x1 convolution is for the transition between two stages of ResNet and thus all information should be preserved. As the number of weights in those three kinds of layers accounts for only a very small proportion of the total number of weights, the limited memory saving for binarizing them does not justify the performance degradation caused by the information loss.

For both the 18-layer and the 34-layer networks, the proposed Bi-Real net reduces the memory usage by 11.1 times and 16.0 times individually, and achieves computation reduction of about 11.1 times and 19.0 times, in comparison with the full-precision network. Without using real-valued weights and activations for scaling binary ones during inference time, our Bi-Real net requires fewer FLOPs and uses less memory than XNOR-Net and is also much easier to implement.

Conclusion

In this work, we have proposed a novel 1-bit CNN model, dubbed Bi-Real net. Compared with the standard 1-bit CNNs, Bi-Real net utilizes a simple short-cut to significantly enhance the representational capability. Further, an advanced training algorithm is specifically designed for training 1-bit CNNs (including Bi-Real net), including a tighter approximation of the derivative of the sign function with respect the activation, the magnitude-aware gradient with respect to the weight, as well as a novel initialization. Extensive experimental results demonstrate that the proposed Bi-Real net and the novel training algorithm show superiority over the state-of-the-art methods. In future, we will explore other advanced integer programming algorithms (e.g., Lp-Box ADMM ) to train Bi-Real Net.

References