Towards Lossless Binary Convolutional Neural Networks Using Piecewise Approximation

Baozhou Zhu, Zaid Al-Ars, Wei Pan · DOI

Abstract

Binary Convolutional Neural Networks (CNNs) can significantly reduce the number of arithmetic operations and the size of memory storage, making the deployment of CNNs on mobile or embedded systems more promising. However, the accuracy degradation of single and multiple binary CNNs is unacceptable for modern architectures and large-scale datasets like ImageNet. In this paper, we propose a Piecewise Approximation (PA) scheme for multiple binary CNNs which lessens accuracy loss by approximating full-precision weights and activations efficiently while maintaining the parallelism of bitwise operations. Unlike previous approaches, the proposed PA scheme segments the full-precision weights and activations piece-wisely and approximates each piece with a scaling coefficient. Our implementation on ResNet with different depths on ImageNet reduces the Top-1 and Top-5 classification accuracy gap compared with full precision to approximately 1.0%.

Introduction

Binary Convolutional Neural Networks (BCNNs) represent the "holy grail" for deploying deep learning on edge devices. By squashing 32-bit weights and activations into a single bit, they offer massive savings in memory and a dramatic speedup via bitwise operations. However, standard BCNNs typically represent values as either +1 or -1. While efficient, this "all-or-nothing" approach discards a massive amount of information, leading to significant accuracy drops—often exceeding 10% on challenging benchmarks like ImageNet.

Existing "multiple binary" approaches, such as ABC-Net, attempt to mitigate this by using a linear combination of several binary bases. Yet, these methods still struggle to bridge the gap to full-precision models. The fundamental challenge lies in approximating the complex, often Gaussian, distribution of neural network weights and activations without sacrificing the "parallel bitwise" efficiency that makes binarization attractive.

The Piecewise Approximation (PA) Scheme

The core innovation of this work is the Piecewise Approximation (PA) scheme. Rather than attempting to approximate the entire range of values globally, the PA scheme segments the distribution into $M$ pieces for weights and $N$ pieces for activations.

Overview of the Piecewise Approximation (PA) scheme for binary convolutions.

Weight and Activation Segmentation

  1. Piecewise Weight Approximation: The weight distribution (typically Gaussian) is divided into segments based on standard deviation. Each segment is approximated by a scaling coefficient ($\alpha$) and a binary base.
  2. Piecewise Activation Approximation: Similarly, activations are segmented. Crucially, the endpoints ($v_i$) and scaling coefficients ($\beta_i$) for activations are trainable parameters, allowing the model to learn the optimal "slicing" strategy during training.

Hardware-Friendly Logic

Unlike most BCNNs that use $\{-1, +1\}$, this scheme utilizes $\{0, 1\}$. In hardware implementations (FPGA/ASIC), an AND gate is roughly half the size and power of an XNOR gate. By using $\{0, 1\}$, the convolution becomes a series of AND and popcount operations, significantly reducing the silicon area and power footprint of the resulting AI chip.

Distribution Fitting and Parallelism

By "slicing" the Gaussian distribution, the PA scheme captures the nuances of the original values much more effectively than a global scaling factor. Even with multiple bases, parallelism is preserved: a convolution with $M$ weight bases and $N$ activation bases can be computed as $M \times N$ parallel bitwise convolutions.

Comparison between full-precision weight distributions (a) and the discretized approximated weights (b) using the PA scheme.

As shown in the figure above, the PA scheme effectively transforms the continuous full-precision distribution into a set of discrete peaks that closely follow the original density, preserving the representational power of the network.

Experimental Results

The PA scheme was evaluated on ImageNet (ILSVRC2012) and PASCAL VOC for object detection.

  • ResNet-18: With $M=8$ weight bases and $N=7$ activation bases, the model achieved 68.1% Top-1 accuracy, just 1.2% shy of the 69.3% full-precision baseline.
  • ResNet-50: PA-Net achieved 74.3% Top-1 (an 1.8% gap), significantly outperforming ABC-Net which lagged at 70.1% (a 6.0% gap).
  • Efficiency: PA-ResNet50 requires 5.07x less memory than its full-precision counterpart and achieves a 2.68x speedup in terms of FLOPs.
  • Object Detection: On the SSD300 task, binarizing only the weights resulted in a negligible 1.82 mAP drop, demonstrating the method's versatility beyond simple classification.

Conclusion

The Piecewise Approximation scheme provides a robust framework for making binary networks practical for high-stakes applications where accuracy cannot be sacrificed for efficiency. By intelligently segmenting distributions and leveraging hardware-efficient $\{0, 1\}$ logic, it achieves near-lossless performance. Future work may address the training overhead associated with multiple binary bases and explore larger batch sizes to further narrow the accuracy gap.

Summary updated

BibTeX
@misc{zhu2020towards,
  author = {Baozhou Zhu and Zaid Al-Ars and Wei Pan},
  title = {{Towards Lossless Binary Convolutional Neural Networks Using Piecewise Approximation}},
  year = {2020},
  eprint = {2008.03520},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2008.03520},
}
Figure