Network Binarization via Contrastive Learning

Yuzhang Shang, Dan Xu, Ziliang Zong, Liqiang Nie, Yan Yan

Abstract

Binary Neural Networks (BNNs) offer significant computational efficiency but typically suffer from substantial accuracy degradation due to information loss during activation binarization. We present Contrastive Mutual Information Maximization (CMIM), a framework that treats full-precision and binary activations as dual views of the same input. By maximizing mutual information through contrastive learning, CMIM preserves critical feature nuances, achieving state-of-the-art performance across classification, segmentation, and depth estimation tasks without increasing inference overhead.

Introduction

Deep learning models are notoriously resource-hungry, limiting their deployment on edge devices. Binary Neural Networks (BNNs) address this by quantizing weights and activations to just 1-bit (typically -1 and +1). This reduction can decrease storage requirements by 32x and accelerate computation via efficient bitwise operations.

However, the "information degradation" caused by binarizing activations remains a major bottleneck. While previous research successfully reduced error in weight binarization, squashing continuous, high-precision activations into a single bit loses the subtle nuances required for complex feature representation. CMIM aims to recover this lost information by ensuring binary activations retain as much "knowledge" from their original full-precision versions as possible.

Methodology: CMIM Framework

The core innovation of CMIM is treating the binarization process as a contrastive learning problem. In a standard BNN forward pass, a latent full-precision activation ($A_F$) is generated just before the sign function converts it into a binary activation ($A_B$). CMIM views $A_F$ and $A_B$ as two different "augmentations" or "views" of the same input sample.

The CMIM framework compared to standard contrastive instance learning.

Mutual Information Maximization

To ensure $A_B$ is a high-quality representative of $A_F$, the framework maximizes the Mutual Information (MI) between them using Noise-Contrastive Estimation (NCE). The training objective involves two primary forces:

  • Positive Pairs: The model "pulls" together the binary activation and the full-precision activation derived from the same image.
  • Negative Pairs: The model "pushes" apart the binary activation of one image from the full-precision activations of all other images in the batch (and from a memory bank of previous samples).
Visualization of the contrastive space where positive pairs are pulled together and negative pairs are pushed apart.

Layer-wise Alignment

Unlike methods that only optimize the final output, CMIM applies this contrastive loss across multiple layers. A weighting scheme ($\beta$) balances the influence of different layers, typically emphasizing later, more semantic layers to ensure robust feature representation throughout the backbone.

Key Results and Insights

CMIM consistently outperforms existing state-of-the-art (SoTA) binarization methods across various benchmarks:

  • ImageNet Classification: On ResNet-18, CMIM reached 62.5% Top-1 accuracy, significantly bridging the gap to full-precision accuracy (~69.6%) compared to standard binarization methods.
  • Generalization: The model showed superior performance in semantic segmentation and depth estimation on the NYUD-v2 dataset, proving that the learned binary features are robust and transferable to tasks beyond simple classification.
  • Feature Discriminability: t-SNE visualizations demonstrate that CMIM produces tighter, more distinct clusters for different classes than previous methods like XNOR-Net or IR-Net.

By penalizing "activation flips" (unintended sign changes) through negative pair pushing, the model forces binary features to be more discriminative. Crucially, CMIM is a "pile-up" module—it is a loss function used only during training. The final model architecture and inference speed remain identical to a standard BNN.

Conclusion

CMIM effectively addresses the information bottleneck in BNNs by leveraging contrastive learning to align binary and full-precision feature spaces. While it introduces additional training complexity and hyperparameter tuning, the resulting performance gains in accuracy and task generalization make it a powerful tool for developing efficient, high-performance quantized networks.

Summary updated

BibTeX
@inproceedings{shang2022network,
  author = {Yuzhang Shang and Dan Xu and Ziliang Zong and Liqiang Nie and Yan Yan},
  title = {{Network Binarization via Contrastive Learning}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  url = {https://openreview.net/forum?id=8U80d9NnMz},
}
Figure