Introduction
Binary Neural Networks (BiNNs) offer a compelling solution for deploying deep learning on resource-constrained devices like mobile phones and IoT sensors. By restricting weights to just two values (e.g., -1 and +1), BiNNs can potentially reduce model size by 32x and drastically cut power consumption. However, they are notoriously difficult to train. Standard calculus-based optimization (gradient descent) fails because weights are discrete—a weight cannot be "slightly more +1."
To bypass this discrete optimization problem, researchers have historically relied on heuristics like the Straight-Through Estimator (STE), which pretends weights are continuous during the backward pass, or Bop, which uses inertia to flip bits. While effective in practice, these methods lack a rigorous theoretical foundation. This paper introduces BayesBiNN, a principled optimizer derived from the Bayesian learning rule that not only explains why these heuristics work but also equips BiNNs with uncertainty estimation and continual learning capabilities.
The BayesBiNN Approach
Instead of searching for a single optimal set of binary weights, BayesBiNN treats training as a distribution-learning problem. The goal shifts to finding the best probability distribution (specifically a Bernoulli distribution) over the binary weights.
- The Bayesian Learning Rule: The authors employ a natural gradient descent approach on a variational objective, updating the "natural parameters" of the weight distribution rather than the weights directly.
- Gumbel-Softmax Relaxation: To make this discrete optimization differentiable, BayesBiNN utilizes the Gumbel-softmax trick, allowing gradients to flow through a "relaxed" continuous approximation of the binary weights.
Crucially, this framework unifies existing heuristics. The paper demonstrates that the mysterious "latent weights" in STE and the "momentum" in Bop are actually approximations of the natural parameters in the BayesBiNN framework. As the temperature of the BayesBiNN distribution approaches zero, its behavior closely mirrors the hard sign function of STE.
Key Insights and Results
Uncertainty and Smoother Predictions
Because BayesBiNN maintains a probability distribution, it inherently understands its own uncertainty—a feature standard BiNNs lack. By averaging predictions over multiple weight samples (the "mean" prediction), BayesBiNN produces smoother, more realistic outputs compared to the jagged predictions typical of STE.
This is visually evident in classification tasks like the synthetic "Two Moons" dataset. While STE draws a hard, overconfident boundary across the entire space, BayesBiNN's mean prediction shows decreasing confidence (fading colors) in regions far from the training data, effectively saying "I don't know" when faced with out-of-distribution inputs.
Solving Catastrophic Forgetting
Standard neural networks, especially BiNNs, suffer from catastrophic forgetting when learning new tasks sequentially. BayesBiNN introduces Variational Continual Learning (VCL) to the binary domain. When learning a new task, the model uses the learned distribution from the previous task as a "prior." This prevents the network from drastically altering weights that were critical for earlier tasks. In Permuted MNIST experiments, BayesBiNN maintained high accuracy across sequential tasks, whereas standard BiNNs suffered massive performance drops on older tasks.
Competitive Accuracy
Despite the added benefits of uncertainty and continual learning, BayesBiNN remains highly competitive on standard metrics. On the CIFAR-100 benchmark, BayesBiNN achieved 73.68% accuracy, outperforming STE Adam (72.89%) and Bop (69.58%), and closing the gap with full-precision models (74.83%).
Limitations and Future Work
While BayesBiNN offers a robust theoretical foundation and new capabilities, it comes with trade-offs:
- Computational Overhead: The training process is more complex than standard STE, requiring sampling and natural gradient calculations.
- Inference Latency: Obtaining the best uncertainty estimates requires multiple forward passes. However, using the "mode" prediction (the most likely binary weights) remains fast and accurate for standard inference.
- Scope: The current work focuses primarily on binary weights. Extending this Bayesian framework to fully binarized pipelines (including binary activations) remains an exciting avenue for future research.
Summary updated