Learning Discrete Weights and Activations Using the Local Reparameterization Trick

Guy Berger, Aviv Navon, Ethan FetayaarXiv 2023 · DOI

Abstract

Training neural networks with discrete weights and activations is essential for efficient deployment on resource-constrained edge devices. However, the non-differentiable nature of discretization functions typically necessitates biased gradient estimators. This paper introduces LAR-nets, a framework that leverages the Local Reparameterization Trick and Gumbel-Softmax sampling to enable fully differentiable training of binary networks. By treating weights as distributions and approximating pre-activations as Gaussians, LAR-nets achieve state-of-the-art performance on CIFAR-10 and CIFAR-100 benchmarks while maintaining high weight sparsity.

Introduction

The deployment of deep learning models on edge devices, such as mobile phones and IoT sensors, is often limited by memory and power constraints. Binarization—restricting weights and activations to {-1, +1}—offers a compelling solution by replacing expensive floating-point operations with efficient bitwise logic. Despite these benefits, training binary networks is challenging because the sign function has a zero derivative almost everywhere, rendering standard backpropagation ineffective. While Straight-Through Estimators (STE) are commonly used to circumvent this, they introduce gradient bias that can degrade model performance.

Methodology

The proposed LAR-net (Local Activation Reparameterization network) addresses the limitations of STEs by adopting a probabilistic perspective on network training. The framework is built upon three primary components:

Local Reparameterization Trick (LRT)

Instead of optimizing point-estimate weights, LAR-nets treat weights as stochastic variables. According to the Central Limit Theorem, the weighted sum of these stochastic inputs (the pre-activation) can be modeled as a continuous Gaussian distribution. This transformation allows the network to operate on differentiable parameters (mean and variance) rather than discrete values.

Differentiable Activation Sampling

To maintain differentiability while producing discrete outputs, the authors utilize the Gumbel-Softmax trick. By calculating the probability of an activation being +1 or -1 from the Gaussian pre-activation, the network can sample discrete values in a way that allows gradients to flow back to the distribution parameters.

Architecture comparison: (a) computational graph of the differentiable sampling, (b) LAR-net layer structure, and (c) standard binary network layer.

Distributional Batch Normalization

Standard Batch Normalization is incompatible with the probabilistic nature of LAR-nets. Consequently, a modified version of BN was developed to normalize the means and variances of the activation distributions directly, ensuring consistency across the network's layers.

Experimental Results

LAR-nets were evaluated using ResNet-18 and VGG-small architectures on the CIFAR-10 and CIFAR-100 datasets. The method demonstrated superior accuracy compared to existing binarization techniques. For instance, on CIFAR-10, LAR-net achieved 92.34% accuracy using 2-bit weights and 1-bit activations, outperforming previous leaders like IR-Net (91.5%) and MPT (91.9%). On CIFAR-100, it set a new benchmark at 68.35% accuracy.

Beyond accuracy, LAR-nets naturally induce weight sparsity, with approximately 43-44% of weights becoming zero. This sparsity provides additional opportunities for memory optimization beyond simple quantization.

Discussion and Key Insights

A critical finding in the development of LAR-nets was the impact of entropy in the final layers. High entropy in the output distribution can lead to excessive randomness, which negatively affects classification performance. To mitigate this, the authors implemented a "cooling" strategy by reducing the learning rate for the final fully-connected layer, effectively stabilizing the distribution.

Entropy trends during training, illustrating the dynamics that necessitate specific management of the final layer's distribution.

Despite its successes, the framework has limitations. It currently relies on pre-trained full-precision models for initialization, and the first and last layers remain in 32-bit precision. Additionally, the use of Monte Carlo sampling increases training complexity compared to deterministic methods.

Conclusion

LAR-nets provide a mathematically rigorous alternative to heuristic-based binary network training. By integrating the Local Reparameterization Trick with differentiable sampling, the framework achieves state-of-the-art results for low-bitwidth models, paving the way for more efficient AI on the edge.

Summary updated

BibTeX
@misc{berger2023learning,
  author = {Guy Berger and Aviv Navon and Ethan Fetaya},
  title = {{Learning Discrete Weights and Activations Using the Local Reparameterization Trick}},
  year = {2023},
  eprint = {2307.01683},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.01683},
}
Figure