Bayesian Neural Networks (BNNs) replace fixed weights with probability distributions, enabling uncertainty quantification. This tutorial demonstrates how to implement BNNs in R using the {kindling} v0.3.0 package within a {tidymodels} workflow. It covers the theoretical foundations (variational inference, reparameterisation trick, ELBO loss), setup with LibTorch, and a practical classification example on the iris dataset using the train_nnsnip() interface with custom BayesLinear layers. Two training approaches are shown: standard cross-entropy loss and a custom ELBO loss, with the latter improving accuracy from 66.7% to 84.7%.
Sort: