                                   Do BNNs Actually Behave Like Bayesian Models?



• HMC. For HMC inference, we use the adaptive No-U-Turns (NUTS) sampler (Section B.1), running four chains in

  parallel, each initialized to independent MAP solutions. For larger networks, this choice of initialization proved crucial,

  often not mixing when initialized randomly, hinting at the fact that certain parts of the weight space are ill-conditioned,

  and HMC does not explore the whole space.

  After a burn-in, we use 150 samples from each chain to make predictions, i.e., 600 samples in total.

• VI. We use mean-field Gaussian VI, as in Section B.2. In our the KL term of Equation (12) between the prior and

  variational distribution is analytic, as both are Gaussian, so NumPyro can use the stochastic gradient estimate of

  Equation (14).

  To deal with the high variance of the gradient estimates, in line with standard practice (Section B.2) we use a number

  of tweaks:

                                                                                             \(β)

     – We initialize the variational variances to small values (10−5 ) so that Var ∇ψ LQ (ψ; D) is small initially.

                                                                                                      



                             \(β)                           \ 

                                                            (β)                          Pn

       Intuitively, Var ∇ψ LQ (ψ; D) is small if Var LQ (ψ; D) = Varθ∼q(·;ψ) ( i=1 log p(yi | xi , θ)) is, which in

       turn is small when Varθ∼q(·;ψ) (θ) is small.

     – We also use momentum through the Adam (Kingma & Ba, 2014) optimizer, and gradient clipping to smooth out

       the optimization trajectory.

     – Lastly, we use the β-ELBO (Equation (16)) with a suitable β < 1 as the maximization objective. This is necessary

       for more stability during optimization, and better posterior fit (Farquhar et al., 2020a).

       We pick β = 0.325 for the small network and β = 0.05 for the larger network, based on a grid search comparing

       the posterior predictive uncertainty of the resulting posterior to the HMC approximation.

• Laplace. We use the diagonal approximation to the empirical Fisher information matrix I(θb MAP ) from Section B.3.

  Although many in practice use the more expressive K-FAC approximation, there are cases to be made for the diagonal

  approximation (Farquhar et al., 2020b), and we have not found even the full-rank Hessian or empirical Fisher to give

  qualitatively different posteriors.

  To increase the stability of the curvature, we need to add a shrinkage factor λ to the precisions. The diagonal of the

  curvature of the loss function l(θ) is

                                                      2              2 !⊤

                                                 ∂l(θ)            ∂l(θ)

                                                          ,...,               .

                                                  ∂θ1              ∂θp

  Adding the shrinkage term and inverting element-wise, we get the scales of the isotropic Gaussian posterior:

                                                  v                   !

                                                  u  ∂l(θ) 2

                                                  u

                                             σi = t1              +λ .

                                                           ∂θi



  The added shrinkage decreases the isotropic Gaussian parameter scales, making the posterior more confident in the

  MAP solution.

  It is also related to the cold posterior phenomenon, artificially making the posterior approximation sharper by decreasing

  the variance of the Gaussian in each direction. We pick λ = 300 for the small network and λ = 2000 for the large

  network, based on a grid search comparing the posterior predictive uncertainty of the resulting posterior to the HMC

  approximation.

• SWAG. Our SWAG implementation relies on the Optax SWAG library (activatedgeek, 2023). 400 samples are collected

  during high learning-rate gradient descent, and a rank-20 Gaussian is fitted to them. Based on similar grid search

  tuning, η = 0.02 for the small network and η = 0.01 for the larger network.









                                                           24

