Learning Discrete Weights Using the Local Reparameterization Trick

Oran Shayer, Dan Levi, Ethan Fetaya

Introduction

Deep Neural Networks (DNNs) are computationally expensive. While they perform miracles on high-end GPUs, running them on edge devices—like the low-power chips in electric vehicles or mobile phones—remains a challenge. One effective solution is to use discrete weights: instead of 32-bit floating-point numbers, networks use binary ({-1, 1}) or ternary ({-1, 0, 1}) values. This eliminates the need for complex multiplications and drastically slashes memory usage.

The catch is that you cannot easily train a discrete network using standard calculus. Gradient descent requires smooth, continuous functions, but discrete weights are jumpy and non-differentiable. Previous fixes, like the "straight-through estimator," essentially guessed a gradient, but these heuristics often lead to a significant drop in accuracy compared to standard networks.

This paper introduces LR-nets (Local Reparameterization Networks), bridging the performance gap between high-precision neural networks and hardware-friendly discrete networks. By applying the Local Reparameterization Trick to the Central Limit Theorem, the authors transform the non-differentiable problem of discrete weights into a smooth, trainable Gaussian approximation that achieves near-full-precision accuracy.

Methods: The LR-net Approach

The core strategy of LR-nets isn't to make the weights continuous, but to make the activations continuous.

  1. Stochastic Weights: The authors treat each weight as a random variable sampled from a discrete distribution (e.g., a weight has a certain probability of being -1, 0, or 1).
  2. The CLT Shortcut: Instead of actually sampling thousands of discrete weights (which is slow), they invoke the Lyapunov Central Limit Theorem (CLT). They argue that the "pre-activation" (the sum of weights times inputs) will naturally follow a Gaussian (normal) distribution, even if the individual weights are discrete.
Gaussian approximation of pre-activations
  1. The Local Reparameterization Trick: Since the pre-activation is now a smooth Gaussian "bell curve," they can use the reparameterization trick. This allows them to backpropagate gradients through the parameters of the distribution (the probabilities) rather than the discrete samples themselves.
  2. Entropy Regularization: To keep training stable, they use two specific tricks:
  3. Probability Decay: For ternary weights, they add a penalty to prevent the model from becoming "too certain" too early, which helps avoid bad local minima.
  4. Beta Regularization: For binary weights, they do the opposite, pushing probabilities toward 0 or 1 to ensure the final model is truly discrete.

Key Insights

  • The "Smooth" Approximation: The most elegant insight is that while a single binary weight is "chunky" and hard to differentiate, the sum of hundreds of binary weights is smooth and predictable. This allows the authors to use principled math where others used heuristics.
  • Ternary > Binary: The authors found that ternary weights ({-1, 0, 1}) are significantly easier to train and more effective than binary weights. This is because the "zero" weight allows a neuron to effectively "turn off" its influence on certain features, providing a level of sparsity that binary networks lack.
  • CLT Holds in Small Layers: Surprisingly, the Gaussian approximation works well even in the first layers of a network where the number of inputs is relatively small (e.g., a 3x3 convolution with only 27 elements).

Datasets and Results

The authors evaluated LR-nets on three standard computer vision benchmarks: MNIST, CIFAR-10, and ImageNet (ILSVRC2012). LR-nets achieved state-of-the-art results for discrete networks at the time of publication, nearly closing the gap with full-precision models:

  • MNIST: The ternary LR-net achieved a 0.50% error rate, actually slightly outperforming the full-precision reference (0.52%).
  • CIFAR-10: The ternary LR-net reached 6.74% error, coming within striking distance of the full-precision model (6.63%).
  • ImageNet: On the challenging ResNet-18 benchmark, the ternary LR-net achieved a 36.5% Top-1 error, significantly beating previous discrete methods like XNOR-Net (48.8%).

Limitations and Future Work

While highly effective, the paper notes that discrete networks require very careful initialization from pre-trained full-precision models to work well. Furthermore, while ternary results were stellar, binary weights still required much more fine-tuning and specific regularization to perform adequately. Finally, while the final deployed model is fast and discrete, the training process is still stochastic and requires floating-point math. The authors suggest that future work could explore "sparse ternary networks" to further reduce overhead during the actual deployment phase.

Summary updated

BibTeX
@inproceedings{shayer2018learning,
  author = {Oran Shayer and Dan Levi and Ethan Fetaya},
  title = {{Learning Discrete Weights Using the Local Reparameterization Trick}},
  booktitle = {International Conference on Learning Representations},
  year = {2018},
  url = {https://openreview.net/forum?id=BySRH6CpW},
}
Figure