Training binary neural networks with real-to-binary convolutions

Brais Martínez, Jing Yang, Adrian Bulat, Georgios Tzimiropoulos

Introduction

Deep learning is rapidly moving toward the "edge," with models increasingly deployed on smartphones, IoT devices, and embedded systems. However, standard neural networks are computationally heavy, relying on 32-bit floating-point (FP32) operations. Binary Neural Networks (BNNs) offer a radical solution: representing weights and activations using just 1 bit. This allows for up to a 32x reduction in memory and significant speedups on CPUs by replacing expensive multiplications with simple bitwise XNOR and pop-count operations.

The primary catch is that BNNs typically suffer from massive "quantization error." For example, a standard ResNet-18 loses about 18% accuracy when binarized using previous state-of-the-art methods like XNOR-Net. This paper introduces "Real-to-Binary" convolutions, a method that significantly narrows this accuracy gap. By combining a progressive teacher-student training strategy with a novel data-driven channel re-scaling mechanism, the authors achieve a record-breaking 65.4% top-1 accuracy on ImageNet with a ResNet-18 architecture—reducing the performance gap to just 5%.

Proposed Methodology

The authors propose three main pillars to improve BNN training and bridge the performance gap:

1. A Strong Baseline

The researchers first curate a "best-of" list of recent BNN architectural tricks. This includes double skip connections, PReLU activations, and a specific layer order (BatchNorm → Binarization → BinaryConv → Activation) to maximize information flow and gradient propagation.

2. Progressive Attention Matching

Instead of training the binary network from scratch, the authors use a "Teacher" (a full-precision network) to guide a "Student" (the binary network). Crucially, they do not just match the final output; they force the student to match the spatial attention maps of the teacher. To make this transition easier, they use a three-step progressive approach:

  • Step 1: An FP32 Teacher guides a "soft-binary" student (using a Tanh function instead of a hard Sign function).
  • Step 2: The soft-binary model becomes the teacher for a model with binary activations but real weights.
  • Step 3: Finally, they train the full BNN (binary weights and activations).

3. Data-Driven Channel Re-scaling

Previous methods used fixed or learned static scaling factors to "un-crush" the binary output. This paper introduces a small gating function. It looks at the rich, real-valued activations before they are binarized and uses that information to predict dynamic scaling factors for the output after the binary convolution.

Data-driven channel re-scaling mechanism using a gating function to predict dynamic scaling factors.

This "look-ahead" mechanism allows the network to adaptively correct the errors introduced by binarization on a per-image basis, adding only about 1% to the total FLOP count.

Key Insights

  • The "Architectural Gap" is Real: Jumping straight from a real-valued teacher to a binary student is too jarring for the optimization process. The progressive bridging (Step 1 → Step 2 → Step 3) is essential for stability and high performance.
  • Attention is All You Need (to Match): Matching raw feature maps is difficult because the distributions of binary vs. real values are drastically different. Matching attention maps (where the network is looking) provides a more flexible and effective supervisory signal.
  • Input-Dependent Scaling: A single scaling factor shouldn't apply to every image. By making the scaling factor a function of the input data via the gating module, the network gains crucial flexibility.

Key Results

The results represent a significant leap for the BNN field, evaluated primarily on ImageNet (ILSVRC12) and CIFAR-100.

Comparison of Top-1 and Top-5 accuracy on ImageNet against previous state-of-the-art BNNs.
  • ImageNet: Their ResNet-18 BNN achieved 65.4% top-1 accuracy. This beats the previous state-of-the-art (XNOR-Net++) by over 8% and the original XNOR-Net by 14%.
  • Closing the Gap: On CIFAR-100, the gap between the full-precision model and the BNN was reduced to less than 3%. On ImageNet, the gap is now roughly 5%, down from the double-digit gaps seen in previous years.
  • Efficiency: Despite the added gating mechanism, the number of floating-point operations (FLOPs) increased by only 1%, maintaining the core efficiency benefits of binarization.

Limitations and Future Work

While the accuracy is impressive, the authors acknowledge that to truly realize the theoretical 58x speedup, one needs a specialized inference engine (like dabnn or BMXNet) optimized for bitwise operations. The gating mechanism, while computationally light, adds a small amount of real-valued overhead that must be carefully managed in hardware implementations.

Future work could involve applying these "real-to-binary" principles to other architectures beyond ResNet, such as MobileNets or Transformers, to see if the performance gap can be closed even further.

Summary updated

BibTeX
@inproceedings{martinez2020training,
  author = {Brais Martínez and Jing Yang and Adrian Bulat and Georgios Tzimiropoulos},
  title = {{Training binary neural networks with real-to-binary convolutions}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
}
Figure