LBBNN: Latent Binary Bayesian Neural Networks Using 'torch'

Lars Skaaret-Lund, Aliaksandr Hubin, Eirik HøyheimOpenalex Unknown 2025 · OpenAlex

Abstract

Latent binary Bayesian neural networks (LBBNNs) are implemented using 'torch', an R interface to the LibTorch backend. This framework supports mean-field variational inference as well as flexible variational posteriors using normalizing flows. The standard LBBNN implementation follows Hubin and Storvik (2024), utilizing the local reparametrization trick for efficiency. Input-skip connections are also supported, as described in Høyheim et al. (2025).

Introduction: The Independence Trap in BNNs

Modern deep learning models are often over-parameterized and prone to overconfidence. Bayesian Neural Networks (BNNs) address this by treating weights as probability distributions, providing a natural measure of uncertainty. However, BNNs traditionally struggle with high computational costs and the "mean-field" assumption, which treats all network weights as independent. This assumption is particularly problematic when dealing with highly correlated data, as it fails to capture the inherent co-dependencies between weights.

Methodology: LBBNN-FLOW and Flexible Posteriors

To overcome these limitations, the authors introduce LBBNN-FLOW. This method combines latent binary variables with Inverse Autoregressive Flows (IAF). Instead of assuming a simple Gaussian distribution for weights, normalizing flows "warp" a simple distribution into a complex, flexible shape capable of capturing weight dependencies.

Comparison between independent weight distributions and a dependent structure mediated by a latent variable.

To maintain computational efficiency, the framework employs the Local Reparametrization Trick (LCRT). By sampling pre-activations rather than individual weights, LCRT significantly reduces variance during training, making the flexible flow-based approach practical for larger networks.

Key Insights: Structural Uncertainty and Sparsity

LBBNNs use a "spike-and-slab" prior to manage structural uncertainty. Latent binary variables effectively act as switches, turning individual weights or nodes on or off. This allows the model to learn sparse architectures automatically.

Example of a sparse network structure where latent binary variables have deactivated specific nodes.

A key finding is that sparsity can actually improve performance. By applying a median probability model—retaining only weights with a >50% inclusion probability—the researchers achieved extreme sparsity (often over 90%) while maintaining or even exceeding the accuracy of dense models. Furthermore, the flow-based models demonstrated superior calibration, providing more reliable uncertainty estimates.

Results and Performance

The LBBNN-FLOW method was evaluated across various tasks. In a simulated logistic regression task with complex correlation, LBBNN-FLOW achieved a True Positive Rate (TPR) of 0.972, far exceeding the 0.681 of mean-field baselines. On image classification benchmarks like KMNIST, the model reached 91.04% accuracy with a density of just 0.096, demonstrating that a fraction of the weights can perform nearly as well as a full dense network. Across nine UCI tabular datasets, the method consistently provided competitive accuracy and improved calibration (ECE).

Conclusion and Future Directions

LBBNN-FLOW represents a significant step forward in building efficient, sparse, and well-calibrated BNNs. By breaking the independence assumption through normalizing flows and maintaining efficiency via LCRT, it offers a robust solution for complex data scenarios. Future work will explore the integration of skip connections and applications in high-dimensional fields like Genome-Wide Association Studies (GWAS).

This paper is based on research by Hubin, Storvik, Skaaret-Lund, and Høyheim.

Summary updated

Abstract

Latent binary Bayesian neural networks (LBBNNs) are implemented using 'torch', an R interface to the LibTorch backend. Supports mean-field variational inference as well as flexible variational posteriors using normalizing flows. The standard LBBNN implementation follows Hubin and Storvik (2024) &lt;<a href="https://doi.org/10.3390%2Fmath12060788" target="_top">doi:10.3390/math12060788</a>&gt;, using the local reparametrization trick as in Skaaret-Lund et al. (2024) &lt;<a href="https://openreview.net/pdf?id=d6kqUKzG3V" target="_top">https://openreview.net/pdf?id=d6kqUKzG3V</a>&gt;. Input-skip connections are also supported, as described in Høyheim et al. (2025) &lt;<a href="https://doi.org/10.48550%2FarXiv.2503.10496" target="_top">doi:10.48550/arXiv.2503.10496</a>&gt;.
BibTeX
@inproceedings{skaaretlund2025lbbnn,
  author = {Lars Skaaret-Lund and Aliaksandr Hubin and Eirik Høyheim},
  title = {{LBBNN: Latent Binary Bayesian Neural Networks Using 'torch'}},
  booktitle = {Openalex Unknown},
  year = {2025},
  doi = {10.32614/cran.package.lbbnn},
}
Figure