Bayesian Neural Networks with Domain Knowledge Priors

## Abstract

Abstract Bayesian neural networks (BNNs) have recently gained popularity due to their ability to quantify model uncertainty. However, specifying a prior for BNNs that captures relevant domain knowledge is often extremely challenging. In this work, we propose a framework for integrating general forms of domain knowledge (i.e., any knowledge that can be represented by a loss function) into a BNN prior through variational inference, while enabling computationally efficient posterior inference and sampling.
Specifically, our approach results in a prior over neural network weights that assigns high probability mass to models that better align with our domain knowledge, leading to posterior samples that also exhibit this behavior.
We show that BNNs using our proposed domain knowledge priors outperform those with standard priors (e.g., isotropic Gaussian, Gaussian process), successfully incorporating diverse types of prior information such as fairness, physics rules, and healthcare knowledge and achieving better predictive performance. We also present techniques for transferring the learned priors across different model architectures, demonstrating their broad utility across various settings.

## 1 INTRODUCTION

While recent advances in deep learning have led to strong empirical performance in many real-world settings, applying deep learning models to high-stakes domains (e.g., healthcare, criminal justice) necessitates correctness, as incorrect predictions can lead to serious consequences. At the same time, it is also crucial for deep learning models to faithfully represent their uncertainty in prediction and avoid making incorrect predictions with high confidence, especially in such domains. Unfortunately, deep learning models trained via empirical risk minimization have been shown to often make errors with high confidence, especially on data points that differ from those observed in the training data distribution [Hendrycks and Gimpel, , Hendrycks et al., ].
Moreover, these models often inherit undesirable biases present in their training data [Larson et al., , Obermeyer et al., ], motivating the development of an approach for incorporating prior knowledge that can counteract and mitigate these issues.

Figure: Figure 1: Our framework (Banana; bottom row) compared to standard practice (top row) for training BNNs. Our method incorporates domain knowledge via a loss function $\phi$ to learn an intermediate step of an informative prior via a variational objective. The informative prior helps encourage models that exhibit desirable behavior.
Refer to caption: x1.png

One principled approach to achieving both correctness and a faithful representation of predictive uncertainty is with Bayesian neural networks [BNNs; MacKay, , , Neal, , Wilson and Izmailov, ].
In BNNs, we treat the neural network weights as random variables and specify a prior distribution over them to represent our a priori belief about what regions of the weight space are plausible. By Bayes’ rule, we can then derive the posterior distribution over the weights conditioned on the training data. The posterior distribution allows us to account for the uncertainty in the model when making predictions, which is especially valuable when making high-stakes decisions.

In the Bayesian setting, selecting a good prior is crucial, and its misspecification for BNNs can force the posterior distribution to contract to suboptimal regions of the weight space [Grünwald and van Ommen, , Gelman et al., , , Fortuin, ], which translates to suboptimal posterior predictive performance. Ideally, the prior should accurately reflect what relevant domain knowledge (e.g., physics rules) specifies as plausible functions for a given prediction problem and help mitigate any undesirable biases learned from the training data. However, the high-dimensionality of the weight space and the nontrivial connection between the weight and function spaces make specifying a prior that reflects domain knowledge extremely challenging [Nalisnick, , Fortuin, ]. Due to such difficulties, uninformative priors that enable tractable sampling and approximate inference are typically used in practice. The most widely used uninformative weight-space prior is the isotropic Gaussian prior [Hernández-Lobato and Adams, ]. Recent works propose to directly specify a function-space prior (e.g., via Gaussian processes (GPs)) to encode functional properties such as smoothness and periodicity [Sun et al., ]. However, existing forms of informative priors are not flexible enough to represent broader forms of domain knowledge.

In this work, we propose a novel approach for incorporating much more general forms of domain knowledge into BNN priors in a semi-supervised learning setup. The key challenge lies in both how to formulate and incorporate such knowledge into the prior and to ensure that this prior leads to computationally tractable posterior inference and sampling. In particular, we focus on domain knowledge for which we can formulate a
loss function $\phi$, such that it captures how well a particular model aligns with the given knowledge. We show that various forms of domain knowledge can be represented in this form (Section 5.1).
For example, for a physics rule, we can define the loss function to measure how much a model’s prediction of the state of a physical system violates the law of conservation of energy.
As another example, if we want a vision model to ignore the background of an image, we can define the loss to be the norm of the gradient of the model’s prediction with respect to the background pixels of the image.
To obtain an informative prior that incorporates such domain knowledge, we propose a variational inference approach to learn a low-rank Gaussian distribution that puts higher probability mass on model weights with low values of the loss $\phi$ on unlabeled data.
The low-rank Gaussian structure of the informative prior enables computationally efficient posterior inference.
We emphasize that with existing approaches for specifying informative priors, it is not clear how to incorporate similar forms of prior knowledge.

We demonstrate that using our learned informative priors for posterior inference in BNNs not only ensures better alignment with domain knowledge (i.e., lower values of $\phi$) but also improves predictive performance across many datasets, where various forms of domain knowledge (e.g., feature importance, clinical rules, fairness constraints) are available.
Notably, our approach outperforms BNNs that use an uninformative isotropic Gaussian prior, as well as those with more specialized—yet unable to flexibly incorporate general forms of domain knowledge—priors.

We also present various techniques, based on maximum mean discrepancy [Gretton et al., ] and moment matching (with SWAG [Maddox et al., ]), for transferring a learned domain knowledge prior across different model architectures to increase their overall utility. In general, a BNN prior is architecture-specific, i.e., we cannot directly use a prior learned for one BNN in another (e.g., with a different number of hidden layers or units).
While relearning a new prior every time is one option, such an approach can be expensive and even infeasible in scenarios when we no longer have access to the loss $\phi$. For example, clinical rules derived from patient data in one hospital(^*^**See Thresholds Used for Defining $\phi_{\text{clinical}}$ in Appendix C.3.) may not be accessible in another due to privacy.
Our empirical results demonstrate that we can efficiently transfer our priors
to different model classes, where models sampled from a transferred prior achieve significantly lower values of $\phi$ compared to models drawn from an isotropic Gaussian prior.

## 2 RELATED WORK

##### Learning with Domain Knowledge.

Many researchers have focused on incorporating domain knowledge or explanations into increasingly black-box deep learning models.
Some approaches directly regularize models to incorporate instances of such domain knowledge [Ross et al., , Rieger et al., , Ismail et al., ].
For example, Rieger et al. [] discourage models from using spurious patches in images for skin cancer detection tasks by penalizing models that place high feature importance on those patches. However, prior knowledge can also come in various forms beyond explanations, including rules from physics [de Avila Belbute-Peres et al., , Seo et al., ], weak supervision [Sam and Kolter, ], invariance [Chen et al., ], explicit output constraints for particular regions of the input space [Yang et al., ] or desirable properties such as fairness
[Zafar et al., , Dwork et al., ].
These works suggest that incorporating domain knowledge can lead to models that are more robust and perform better out-of-distribution. Existing work theoretically analyzes such simple incorporation of domain knowledge as constraints to show benefits in sample complexity [Pukdee et al., ].

In the Bayesian setting, existing works have studied directly regularizing posterior samples [Zhu et al., , Huang et al., ], but none have extensively studied how to obtain BNN priors that incorporate forms of domain knowledge as broad as those aforementioned.
Moreover, using informative priors is more computationally efficient than posterior regularization, as we only need to compute $\phi$ during the pretraining phase for the prior (see Section 4.2) and not for every posterior sample. Our method thus scales better when sampling a large number of posterior samples, allowing a more accurate approximation of the model posterior average.

##### Priors in Bayesian Neural Networks.

As previously mentioned, the high-dimensionality of the weight space for BNNs makes specifying a prior that reflects aforementioned forms of domain knowledge extremely challenging [Nalisnick, , Fortuin, ].
Prior works propose to encode functional properties such as smoothness and periodicity by using a function-space prior (e.g., via GPs [Rasmussen and Williams, ]) [Sun et al., , , Hafner et al., , Tran et al., ],
to encode output constraints for particular regions of the input space into a weight-space prior [Yang et al., ], or to use a set of reference models (e.g., simpler linear models) as priors to regularize the predictive complexity of BNNs [Nalisnick et al., ]. Our work differs from prior work in that we address more general notions of domain knowledge, such as feature importance and fairness, which are difficult to achieve with existing methods (e.g., how does one encode notions of fairness into a GP kernel?).

More recent works propose to leverage advances in self-supervised learning [Henaff, , Chen et al., ] to learn more informative and expressive priors from auxiliary, unlabeled data. Sharma et al. [] propose to learn an informative prior by fixing the parameters of the base encoder to the approximate maximum a posteriori (MAP) estimate from contrastive learning [Chen et al., ]. Shwartz-Ziv et al. [] propose to use a temperature-scaled posterior from a source task as a pretrained, informative prior for the target task, and empirically demonstrate that a BNN with an informative prior consistently outperforms BNNs with uninformative priors (e.g., isotropic Gaussian) and non-Bayesian neural network ensembles in predictive accuracy, uncertainty estimation, and data efficiency.

We remark that, to the best of our knowledge, there are no other existing BNN methods that allow incorporating general forms of domain knowledge into BNN priors. The most relevant prior work by Yang et al. [], which encodes information by upweighting models that satisfy particular constraints on their output space, can be seen as a specific instance of our framework but is not easily applicable to most tasks considered in this paper.

## 3 PRELIMINARIES

We consider a standard semi-supervised learning setting. Let $\mathcal{X}$ be an instance space and $\mathcal{Y}$ be a label space. Let $\mathcal{D}$ be a distribution over $\mathcal{X}\times\mathcal{Y}$. We observe a training dataset of examples $X=\{(x_{1},y_{1}),...,(x_{n},y_{n})\}$ and unlabeled examples $X^{\prime}=\{x_{1}^{\prime},...,x_{k}^{\prime}\}$ drawn from $\mathcal{D}$ and a marginal distribution $\mathcal{D}_{\mathcal{X}}$, respectively. We consider a class of neural networks $\mathcal{H}=\{h_{w}|h_{w}:\mathcal{X}\to\mathcal{Y}\}$, which have weights $w$. Our goal is to learn a neural network $h$ (or a distribution over possible neural networks with a mean) that achieves the lowest loss, or

$$ $\displaystyle\mathrm{err}(h):=\Pr_{(x,y)\sim\mathcal{D}}(\ell(h_{w}(x),y)),$ $$

where $\ell$ is the 0-1 loss for classification, and the $\ell_{1}$ or $\ell_{2}$ loss for regression.

One approach to capture model uncertainty is via BNNs, which models a distribution over neural networks via a distribution over weights, $q(w)$. In practice, it is common to assume a standard isotropic Gaussian prior $q(w)=\prod_{i}\mathcal{N}(w_{i};0,\sigma_{i}^{2})$. This does not capture any prior knowledge about downstream tasks but is primarily used for its computational tractability.
Given a prior $q(w)$ over neural network weights $w$ and labeled data $X$, we can sample from the posterior distribution using stochastic gradient Markov chain Monte Carlo methods such as Stochastic Gradient Hamiltonian Monte Carlo (SGHMC) [Chen et al., ] and Stochastic Gradient Langevin Dynamics (SGLD) [Welling and Teh, ].
In this work, we mainly use SGLD in our experiments (Sections 5.1–5.2) but also consider MultiSWAG [Wilson and Izmailov, ] in our ablations (Section 5.3).

## 4 Domain Knowledge Priors for Bayesian Neural Networks

While existing methods tackle specific desirable properties of a network (e.g., smoothness), it is unclear how to incorporate very general forms of domain knowledge into BNNs, as discussed in Sections 1–2.
We propose to achieve this by incorporating such information into a data-driven prior.

### 4.1 Domain Knowledge Loss

First, we define our notion of domain knowledge. We propose to represent this as a loss function that measures the alignment of a particular model to our domain knowledge.

###### Definition 1

(Domain Knowledge Loss)
A domain knowledge loss function can be expressed as $\phi:\mathcal{H}\times\mathcal{X}\to\mathbb{R}$, which takes inputs $h\in\mathcal{H},x\in\mathcal{X}$ and has $\phi(h,x)\geq 0.$

We capture how well $h$ satisfies our domain knowledge at a point $x$ through this loss function, where a lower loss value implies that $h$ better satisfies the domain knowledge. This definition is quite general, and it is possible to define the loss $\phi$ to capture various notions of domain knowledge including physical rules and information about spurious correlations (see examples of these losses in Section 5.1). We remark that these notions of domain knowledge are functions of the random input data $x$, and thus are difficult to directly encode in function space or via a kernel in a GP prior.

Given this definition of domain knowledge, we want our models to achieve low values of this loss, say having $\mathbb{E}_{x\sim\mathcal{D}_{\mathcal{X}}}[\phi(h,x)]\leq\tau$, where $\tau$ is some threshold. We also remark that this loss can be evaluated solely on unlabeled data, which yields nicely to using this for pretraining or learning priors. Considering losses that use information about labels could be potentially interesting, especially in the case of certain fairness metrics, e.g., equal odds and disparate impact [Hardt et al., , Mehrabi et al., ].

In the frequentist setting, we can incorporate such domain knowledge by simply adding a regularization term based on this surrogate loss [Ross et al., , Rieger et al., , Pukdee et al., ]. For a loss function $\ell$, this yields a regularized objective given by

$$ $\displaystyle\min_{h\in\mathcal{H}}\frac{1}{n}\sum_{i=1}^{n}\ell(h,x_{i},y_{i} )+\lambda\cdot\frac{1}{k}\sum_{i=1}^{k}\phi(h,x^{\prime}_{i}),$ (1) $$

where $\lambda>0$ is the regularization coefficient. Augmented Lagrangian approaches like Eq. (1) can achieve good supervised performance while minimizing the surrogate loss.
A similar approach can be taken in the Bayesian case using posterior regularization [Zhu et al., ], although we focus the scope of this paper on learning informative priors.

###### Definition 1

### 4.2 Learning Informative Priors

We present our method for incorporating domain knowledge in the form of these losses into an informative prior for BNNs. As we want to encourage sampling models that achieve low values of the surrogate loss $\phi$, our goal is to learn a prior that assigns high probability mass to these models, consequently influencing samples from the posterior.

We propose to learn our informative prior by inferring the posterior distribution over $w$ given unlabeled data $X^{\prime}$ and a surrogate loss $\phi$. By Bayes’ rule, this posterior is given by

$$ $\displaystyle p(w|X^{\prime},\phi)\propto p(\phi|w,X^{\prime})\cdot p(w),$ $$

where the weight-space prior $p(w)=\prod_{i}\mathcal{N}(w_{i};0,\sigma_{i}^{2})$ is the commonly used isotropic Gaussian distribution.
Since our goal is to enforce $\phi(h_{w},x)$ to be small, we assume that the likelihood for $\phi$ is given by

$$ $p(\phi|w,x)=\mathcal{N}\left(\phi(h_{w},x);0,\tau^{2}\right),$ $$

where $\tau>0$ is a hyperparameter controlling how much probability mass we want to center about models that most satisfy our domain knowledge. The posterior distribution, which represents our domain knowledge-informed prior that can be used in later tasks, is then given by

$$ $p(w|X^{\prime},\phi)\propto\prod_{x_{i}^{\prime}\in X^{\prime}}\mathcal{N}( \phi(h_{w},x_{i});0,\tau^{2})\cdot p(w).$ (2) $$

Given the intractability of computing the true posterior in Eq. (2), we use variational inference [Kingma and Welling, , Blei et al., ] to approximate it with the low-rank multivariate Gaussian distribution

$$ $\displaystyle q_{\psi}(w)=\mathcal{N}(w;\mu,\Sigma_{r}),\quad\Sigma_{r}=\sum_{ i=1}^{r}v_{i}v_{i}^{T}+\sigma^{2}I,$ (3) $$

where $\psi=(\mu,v_{1},\dots,v_{r})$ and where $\sigma>0$ is a small, fixed value that keeps $\Sigma_{r}$ positive definite and $\mu$ is a vector of real-valued means. We assume that the variational covariance matrix $\Sigma_{r}$ has low rank $r$ for computational efficiency, given that $w$ is generally high-dimensional, which is a standard assumption in practice. As such, the size of our BNN scales as $O(r\cdot n)$, where $n$ represents the number of parameters in the neural network architecture.

##### Our Variational Objective.

We optimize the variational parameters $\psi$
to maximize the evidence lower bound (ELBO) which is given by

$$ $\mathbb{E}_{w\sim q_{\psi}}[\log p(\phi|w,X^{\prime})]-\operatorname{KL}(q_{ \psi}(w)||p(w)).$ (4) $$

This is a lower bound of $\log p(\phi|X^{\prime})$, and optimality is achieved when $q(w)=p(w|\phi,X^{\prime})$.
Since $q(w)$ and $p(w)$ are both multivariate Gaussian distributions, sampling from these distributions is straightforward, and the KL divergence term between $p(w)$ and $q(w)$ admits a closed form that can be computed efficiently. For a given set of unlabeled examples $X^{\prime}$, we thus seek to optimize the objective

$$ $\displaystyle\max_{\psi}\left(\mathbb{E}_{w\sim q_{\psi}}\left[-\sum_{i=1}^{k} \frac{\phi(h_{w},x)^{2}}{2\tau^{2}}\right]-\text{KL}(q_{\psi}(w)||p(w))\right).$ $$

We note that as $\tau\to\infty$, we recover $q_{\psi}(w)=p(w)$. We then use the learned intermediate posterior distribution $q_{\psi}(w)$ as our informative prior for downstream tasks, performing posterior sampling via standard methods (e.g., SGLD, MultiSWAG) in practice. Since our informative prior $q_{\psi}(w)$ is a low-rank Gaussian distribution, we remark that the computational overhead of approximate inference with the informative prior is similar to using an isotropic Gaussian.

### 4.3 Transferring Informative Priors

A key limitation of the learned priors is that they are architecture-specific. To make them usable for downstream tasks where other model architectures may be more suitable, it is important to identify effective techniques for transferring these learned priors.
Our proposed strategy is to match functions drawn from the learned informative prior and a target prior distribution for the new model architecture.

Formally, let $\mathcal{H}_{1}=\{h_{w}\mid h_{w}:\mathcal{X}\to\mathcal{Y}\}$ represent the hypothesis class of our original model architecture, with a corresponding informative prior $q_{\psi_{1}}(w)$. We want to learn an informative prior for a different class of networks $\mathcal{H}_{2}=\{h_{u}\mid h_{u}:\mathcal{X}\to\mathcal{Y}\}$. We hope to learn a distribution $q_{\psi_{2}}(u)$ such that the distributions over $\mathcal{H}_{1}$ and $\mathcal{H}_{2}$ induced by $w\sim q_{\psi_{1}}(w)$ and $u\sim q_{\psi_{2}}(u)$ are close. As we consider low-rank Gaussian priors, we can efficiently draw samples from $q_{\psi_{1}}(w)$ and $q_{\psi_{2}}(u)$, and this motivates us to learn $\psi_{2}$ such that the set of functions $\{h_{w_{1}},\dots,h_{w_{n}}\}\subseteq\mathcal{H}_{1}$ and $\{h_{u_{1}},\dots,h_{u_{n}}\}\subseteq\mathcal{H}_{2}$ are similar when $w_{i}\sim q_{\psi_{1}}(w)$, $u_{i}\sim q_{\psi_{2}}(u)$.
Since the members of each set are functions, it is difficult to compare them directly. If we have access to a set of unlabeled examples $X^{\prime}=\{x_{1},\dots,x_{m}\}$, we can instead make sure that the evaluation of each function on $X^{\prime}$ are similar, i.e., $W:=\{h_{w_{1}}(X^{\prime}),\dots,h_{w_{n}}(X^{\prime})\}$ and $U:=\{h_{u_{1}}(X^{\prime}),\dots,h_{u_{n}}(X^{\prime})\}$ are similar when $h(X^{\prime})=(h(x_{1}),\dots,h(x_{m}))\in\mathbb{R}^{m}$.

##### Moment Matching.

We consider simple approaches to match the moments of the two distributions $q_{\psi_{1}}(w)$ and $q_{\psi_{2}}(u)$, whose objectives are given by

$$ $\displaystyle\hat{M}_{1}$ $\displaystyle=\mathbb{E}_{x}[(\mathbb{E}_{w\sim q_{\psi_{1}}(w)}[h_{w}(x)]- \mathbb{E}_{u\sim q_{\psi_{2}}(w)}[h_{u}(x)])^{2}]$ $\displaystyle\hat{M}_{2}$ $\displaystyle=\mathbb{E}_{x}[(\mathbb{E}_{w\sim q_{\psi_{1}}(w)}[h_{w}(x)^{2}] -\mathbb{E}_{u\sim q_{\psi_{2}}(w)}[h_{u}(x)^{2}])^{2}],$ $$

where $\hat{M}_{1}$ is used to match only the first moment, and $\hat{M}_{2}$ is used to match the first two moments.

##### Maximum Mean Discrepancy.

We propose to minimize the kernel maximum mean discrepancy (MMD) [Gretton et al., , Li et al., ] between $W$ and $U$, where the objective is given by

$$ $\displaystyle\hat{M}(W,U)$ $\displaystyle=\frac{1}{n(n-1)}\sum_{i=1}^{n}\sum_{j\neq i}k(h_{w_{i}}(X^{ \prime}),h_{w_{j}}(X^{\prime}))$ $\displaystyle+\frac{1}{n(n-1)}\sum_{i=1}^{n}\sum_{j\neq i}k(h_{u_{i}}(X^{ \prime}),h_{u_{j}}(X^{\prime}))$ $\displaystyle+\frac{1}{n^{2}}\sum_{i=1}^{n}\sum_{j=1}^{n}k(h_{w_{i}}(X^{\prime }),h_{u_{j}}(X^{\prime})),$ $$

and $k$ represents a kernel. MMD only requires access to the samples from each distribution which fit well with our scenario as these samples are easy to draw.

Meanwhile, we remark that other approaches, such as learning $\psi_{2}$ to fool a discriminator network that is trained to distinguish between two set of samples [Goodfellow et al., , Radford et al., , Arjovsky et al., , Li et al., , Bińkowski et al., ] or directly working with kernel two-sample tests for functional data [Wynne and Duncan, ], can also be used.
A main benefit of studying these prior transferring approaches is that they enable transferring domain knowledge when we no longer have access to the function $\phi$. This approach can help support the open-source release and usage of informative priors, similar to how pretrained models are currently used in practice.

## 5 EXPERIMENTS

We compare our method of learning an informative prior through variational inference, which we refer to as Banana, against
BNN implementations with various priors, including the standard isotropic Gaussian, a Gaussian with hyperparameters optimized via empirical Bayes using Laplace’s method [Daxberger et al., ], and a prior that is learned to match a GP prior with a RBF kernel [Tran et al., ].
We note that the baseline matched to a GP prior (single-output) is not evaluated on our regression dataset (Pendulum), which has multivariate outputs.

For all prediction tasks described below, we use a two-layer feedforward neural network with ReLU activations.
As noted in Shwartz-Ziv et al. [], the scaling of the prior in the downstream task has a significant impact on both performance as well as the weighting of our domain knowledge. As such, we add a hyperparameter $\beta>0$ that scales the KL divergence term in Eq. (4), to control better the tradeoff between using prior information and fitting the observed labeled data.
In computing our posterior averages for each method, we average in the logit space of the posterior samples. We also explore averaging in the output space of posterior samples in Appendix A.1
We provide additional experimental details in Appendix B.

**Table 1: Comparison of Banana (with posterior averaging over logits) against BNNs with different priors in terms of accuracy, AUROC, or $L_{1}$ loss and $\phi$ ($\pm$ s.e.), when averaged over 5 seeds. $\uparrow$ denotes that higher is better, and $\downarrow$ denotes that lower is better. We bold the method with the best performance and the lowest value of $\phi$. - denotes when a method is not applicable.**
|  | DecoyMNIST | MIMIC-IV | Pendulum |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| Method | Accuracy ($\uparrow$) | $\phi_{\text{background}}$ | AUROC ($\uparrow$) | $\phi_{\text{clinical}}$ | $L_{1}$ Loss ($\downarrow$) | $\phi_{\text{energy_damping}}$ |
| BNN + Isotropic | 76.41 $\pm$ 0.71 | 1.06 $\pm$ 0.06 | 0.6981 $\pm$ 0.0003 | 0.1624 $\pm$ 0.0005 | 0.0036 $\pm$ 0.0001 | 0.0319 $\pm$ 0.0026 |
| BNN + Laplace | 76.47 $\pm$ 0.70 | 1.14 $\pm$ 0.04 | 0.6980 $\pm$ 0.0002 | 0.1625 $\pm$ 0.0009 | 0.0043 $\pm$ 0.0006 | 0.0367 $\pm$ 0.0100 |
| BNN + GP Prior | 75.49 $\pm$ 0.70 | 1.54 $\pm$ 0.04 | 0.6979 $\pm$ 0.0002 | 0.1628 $\pm$ 0.0008 | - | - |
| Banana | 78.21 $\pm$ 0.40 | 0.44 $\pm$ 0.01 | 0.6983 $\pm$ 0.0001 | 0.1619 $\pm$ 0.0005 | 0.0041 $\pm$ 0.0007 | 0.0025 $\pm$ 0.0010 |

### 5.1 Datasets and Domain Knowledge Losses

##### Fairness in Hiring Decisions.

We demonstrate that our method can incorporate notions of fairness on the Folktables dataset [Ding et al., ]. We consider the task of determining whether a particular applicant gets employed, within the Alabama subset of the data in 2018. We focus on group fairness as our underlying domain knowledge, where we define our $\phi$ as

$$ $\displaystyle\phi_{\text{group_fairness}}(h,x)=\left(p(h(x)|A=a)-p(h(x)|A=b) \right)^{2},$ $$

where $A$ denotes a random variable for a particular group, such as race or gender. In our experiments, we consider $A=a$ to be the subgroup that corresponds to Black people and $B=b$ to correspond to White people.
We note that satisfying this domain knowledge does not necessarily improve predictive performance [Dutta et al., ], although it is a desirable and potentially legal necessity of a model.

##### Feature Importance for Image Classification.

We also demonstrate that our method can incorporate notions of feature importance. We consider the task of ignoring background information which are spurious features on a variant of the MNIST dataset [LeCun et al., ] called DecoyMNIST [Ross et al., ]. On this task, a patch has been added in the background that correlates with different labels at train and test time. Thus, standard supervised learning methods can struggle due to this distribution shift.
Here, we consider domain knowledge of ignoring background pixels in making predictions. We compute this as

$$ $\displaystyle\phi_{\text{background}}(h,x)=||\nabla_{x}h(x)||_{b}^{2},$ $$

where $b$ denotes only the feature indices that correspond to the background. On DecoyMNIST, we access these feature dimensions by looking at the uncorrupted data, which is not used during training. For other tasks, we can generate these background masks via a segmentation network.

##### Clinical Rules for Healthcare Interventions.

We demonstrate how our method can be used to incorporate clinical rules into the prior using the MIMIC-IV dataset [Johnson et al., ]. We reproduce the binary classification task in Yang et al. [], where the goal is to predict whether an intervention for hypotension management (e.g., vasopressors) should be given to a patient in the intensive care unit, given a set of physiological measurements. As in Yang et al. [], we incorporate the clinical knowledge that an intervention should be made if the patient exhibits: (i) high lactate and low bicarbonate levels, or (ii) high creatinine levels, high blood urea nitrogen (BUN) levels, and low urine output.
We can express this knowledge as

$$ $\displaystyle\phi_{\text{clinical}}(h,x)$ $\displaystyle=\mathbf{1}[x\in\mathcal{X}_{c}]\cdot\text{ReLU}(1-h(x)),$ $$

where $h(x)$ is the classifier output, $\mathcal{X}_{c}\subseteq\mathcal{X}$ denotes the subset of the input space that satisfies the conditions specified in the above rules,
and $\text{ReLU}(1-h(x))$ encourages $h(x)$ on such inputs to be close to 1.
We include all details on cohort selection, data preprocessing, and the specification of $\mathcal{X}_{c}$ in Appendix C.3.

Figure: Figure 2: Comparison of samples from the Banana prior (in green) against those from an isotropic Gaussian prior (in red) on the Folktables dataset. The solid line is the Pareto frontier, and the dots represent samples from each prior. Samples from Banana tend to be more Pareto-optimal, achieving higher accuracy while satisfying fairness constraints.
Refer to caption: x2.png

**Table 2: Our proposed methods for transferring priors successfully improve alignment with domain knowledge in BNNs with different architectures. (Top 2 rows) Values of $\phi$ for models drawn from an isotropic Gaussian prior and the learned Banana prior. (Bottom 3 rows) Values of $\phi$ from models with larger architectures drawn from an isotropic Gaussian prior and a prior transferred from Banana via a first moment matching (with SWAG) or MMD. Results are averaged over 5 seeds.**
| Method | DecoyMNIST | Folktables | MIMIC-IV | Pendulum |
| --- | --- | --- | --- | --- |
| Isotropic | $0.2617\pm 0.0168$ | $0.0173\pm 0.0056$ | $0.2867\pm 0.0109$ | $134.0293\pm 9.7799$ |
| Banana | 0.0186 $\pm$ 0.0023 | 0.0119 $\pm$ 0.0099 | 0.0006 $\pm$ 0.001 | 0.0 $\pm$ 0.0 |
| Isotropic (L) | $0.4963\pm 0.0151$ | $0.0231\pm 0.0025$ | $0.2932\pm 0.0091$ | $179.6625\pm 15.9685$ |
| Banana + MMD | 0.0288 $\pm$ 0.0044 | 0.02 $\pm$ 0.0048 | 0.004 $\pm$ 0.002 | 0.0035 $\pm$ 0.0055 |
| Banana + 1st Moment (SWAG) | 0.0015 $\pm$ 0.0005 | 0.0014 $\pm$ 0.0021 | 0.0 $\pm$ 0.0 | 0.0 $\pm$ 0.0 |

##### Physics Rules for Pendulums.

We demonstrate how our method can incorporate physical knowledge into the prior on the double pendulum dataset [Seo et al., , Asseman et al., ]. We consider a regression task where the goal is to predict the next state of double-pendulum dynamics with friction from a given initial state $x=\left(\theta_{1},\omega_{1},\theta_{2},\omega_{2}\right)$ where $\theta_{i},\omega_{i}$ are the angular displacement and the velocity of the $i$-th pendulum, respectively. We incorporate physics knowledge from the law of conservation of energy; since the system has friction, the total energy of the system must be strictly decreasing over time. We can express this knowledge by the following loss:

$$ $\phi_{\text{energy_damping}}(h,x)=\max(E(h(x))-E(x),0),$ $$

where $h(x)$ is the predicted next state and $E(x)$ is a function that maps a given state $x$ to its total energy. This loss penalizes predictions of states with higher total energy.

### 5.2 Results

We present the results comparing our method to the baselines in Table 1. We observe that incorporating the domain knowledge leads to a better-performing classifier than standard BNN approaches with existing techniques to specify priors.
We note that across all tasks, the model averages produced by Banana achieve lower values of $\phi$ than a standard BNN approach that uses an isotropic Gaussian prior.
We note that in some cases, such as on MIMIC-IV, the benefits in terms of $\phi$ are less clear because the domain knowledge loss $\phi_{\text{clinical}}$ is also related to the standard training objective. However, in cases where these domain knowledge losses are not as strongly connected to the training objective (i.e., the notion of patches in DecoyMNIST), the decrease in the value of $\phi$ is much clearer.
We remark that on the pendulum task, there is already sufficient labeled data (18000 samples) so the informative prior information is not necessary for strong performance. As a result, Banana is slightly less performant but better adheres to physical rules.

On the Folktables dataset, $\phi_{\text{group_fairness}}$ may be at odds with the underlying accuracy, i.e., a less performant model may achieve a lower value of $\phi$. As such, we omit this dataset from Table 1 and, rather, present the tradeoff between accuracy and group fairness. In Figure 2, we provide a Pareto frontier of the accuracy and group fairness achieved by posterior samples from our approach, compared to those from a standard BNN. We observe that samples from our informative prior produce models that achieve lower values of group fairness, with no degradations in performance when compared to samples from an isotropic Gaussian prior.

#### 5.2.1 Directly Sampling from the Informative Prior

To analyze how well the informative prior encodes our domain knowledge, we can directly sample from our informative prior and compute the value of domain knowledge loss $\phi$ achieved on our sample (see the first two rows of Table 2), although we note that these models are not necessarily suited for a downstream task. We use the same hyperparameter values for training our informative prior as those selected for the downstream classification/regression task in Table 1. On each dataset, we compute our expected value of $\phi$ over 10 samples from the informative prior.
We observe that across almost every task, our informative prior successfully upweights models that achieve significantly lower values of $\phi$ on their respective datasets when compared to randomly sampling from an isotropic Gaussian distribution, reflected by a posterior average that has much smaller values of $\phi$.

Figure: Figure 3: Change in test accuracy on the DecoyMNIST task when varying the number of mixture components in the informative prior in Banana. Results are averaged over 5 seeds, and the shaded region represents mean $\pm$ s.e.
Refer to caption: x3.png

#### 5.2.2 Transferring Priors to Different Architectures

In addition to comparing the value of $\phi$ achieved by models sampled from our informative prior, we also evaluate the performance of transferring this informative prior to a different model architecture (see the bottom three rows in Table 2). We transfer the prior over a two-layer neural network to another two-layer network with a larger hidden dimension size, where we minimize the difference between first moments (via SWAG [Maddox et al., ]) or MMD with respect to a Gaussian kernel.

We observe that our transferring approach yields informative priors over the new model class that also reflect much smaller values of $\phi$ than standard isotropic Gaussian prior over the larger model architecture, almost fully recovering the same performance as the original prior in many cases. We further compare against other strategies that we propose to transfer this prior in additional ablations in Appendix A.3. These results demonstrate that informative priors learned in Banana can effectively be transferred to different model architectures that may be better suited for the downstream task.

### 5.3 Ablation Studies

##### Alternative Approximations for the Informative Prior.

We assess different approximation schemes for learning the informative prior to better capture the knowledge in $\phi$. Given that variational inference often underestimates the variance of the true posterior [Blei et al., ], which need not be unimodal, we consider approximating Eq. (2) with a mixture $q(w)=\frac{1}{K}\sum_{k=1}^{K}\mathcal{N}(\mu_{k},\Sigma_{r,k})$ of $K$ rank-$r$ Gaussians, via the MultiSWAG method [Wilson and Izmailov, ].
For each $k=1,\ldots,K$, we initialize the model parameters with a different random seed and compute $(\mu_{k},\Sigma_{r,k})$ by averaging over 3 samples (5 epochs apart) from the stochastic gradient descent (SGD) trajectory, after an initial 5 epochs of training. Using each $q_{k}$ as an informative prior, we sample 5 weights from the downstream posterior via SGLD. We average over sampled weights to obtain the final prediction.

Figure 3 shows the change in test accuracy on DecoyMNIST as we vary $K$ from 1 to 5. We find that on average, the test accuracy monotonically increases with increasing $K$ and improves over the test accuracy in Table 1. These results suggest that with a sufficient computational budget, learning a multimodal informative prior can be an effective approach for better capturing our domain knowledge and improving downstream performance. This also shows that a sufficiently complex $q$ is required to fully reap the benefits of using prior information. We study this further in Appendix A.2, where we experiment with higher rank approximations of our prior as well as a diagonalized Gaussian prior approximation.

##### Model Ensemble Size.

With other frequentist methods, computing a model ensemble approximately equivalent to a Bayesian model average [Lakshminarayanan et al., ] requires performing potentially computationally expensive regularization with $\phi$ (or even pretraining in the case of invariances used in self-supervised learning as the form of domain knowledge). On the other hand, a Bayesian approach only needs to train the prior once and can generate multiple samples from the posterior. Given that the computational cost of sampling from the posterior is efficient as in our setting, this can be a significant benefit, specifically when computing this regularization or pretraining is costly.

As such, we run ablation studies to evaluate the performance of Banana’s and other approaches’ ensembles to assess how the number of members of the ensemble impacts the downstream performance of the approaches. We observe that increasing the ensemble size increases performance, until we observe diminishing returns after ensemble sizes of 15, on the DecoyMNIST task (Figure 4). This demonstrates that larger ensembles generally achieve better performance and supports the use of informative priors, which can more efficiently scale to posterior averages with larger ensembles when compared to other regularization-based approaches.

Figure: Figure 4: Change in test accuracy on the DecoyMNIST task when varying the number of models sampled to compute our posterior average in Banana. Results are averaged over 5 seeds, and the shaded region represents mean $\pm$ s.e.
Refer to caption: x4.png

## 6 DISCUSSION

We propose a framework to incorporate general forms of domain knowledge into the priors for BNNs. Empirically, we observe that this can improve the performance of BNNs across several tasks with different notions of domain knowledge and leads to models that exhibit desirable properties. In addition, we provide an effective approach to transfer informative priors across model architectures, resolving an existing problem in the literature. Our results provide new insights into incorporating domain knowledge into priors for Bayesian methods, which can be captured by optimizing a learnable approximation through variational inference.

As a whole, our results support the development of open-source informative priors that practitioners can incorporate into their various specific use cases to encode desirable model properties without the need to deal with $\phi$ directly, irrespective of the desired model architecture. As such, this supports
the foundations for pretraining in the Bayesian setting, by providing a framework to develop and transfer informative priors to new model tasks as desired, similar to pretrained weights or foundation models that are currently released as open-source.

## Acknowledgements

DS was supported by the Bosch Center for Artificial Intelligence, the ARCS Foundation. This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE2140739.
RP was supported by a Bloomberg Data Science PhD fellowship.
DPJ was supported by DARPA via FA8750-23-2-1015 and ONR via N00014-23-1-2368.
YB was supported in part by the AI2050 program at Schmidt Sciences (Grant G-22-64474).
DPJ and YB also gratefully acknowledge the NSF (IIS2211955), UPMC, Highmark Health, Abridge, Ford Research, Mozilla, the PwC Center, Amazon AI, JP Morgan Chase, the Block Center, the Center for Machine Learning and Health, and the CMU Software Engineering Institute (SEI) via Department of Defense contract FA8702-15-D-0002, for their generous support of ACMI Lab’s research.

Bayesian Neural Networks with Domain Knowledge Priors
(Supplementary Material)

## A Additional Experiments

### A.1 Model Averaging

We provide experiments to compare averaging different samples from the posterior distribution in their logit space and in their prediction space. We remark that the Pendulum dataset consists of a regression task, where there is no distinction between logit space and prediction space and, thus, we do not report those results as they are the same. We also note that it is common to average in weight space; this performs quite poorly since we do not control the norms of each layer (i.e., there are no layer norm operations).

**Table A1: A comparison of different ensembling techniques of models sampled from the posterior distribution of Banana. We report accuracy ($\pm$ s.e.) when averaged over 5 seeds.**
|  | DecoyMNIST | Folktables | MIMIC-IV |
| --- | --- | --- | --- |
| Banana - Predictions | 77.51 $\pm$ 0.39 | 81.45 $\pm$ 0.03 | 0.6951 $\pm$ 0.0014 |
| Banana - Logits | 78.21 $\pm$ 0.40 | 81.50 $\pm$ 0.04 | 0.6983 $\pm$ 0.0001 |

We note that there is not a significant difference, although we observe that performing model averaging over the logits of each sample from the posterior distribution achieves potentially higher accuracy than averaging over the discrete predictions (where tiebreaks are simply taken by the first class in the ordering).

Figure: Figure A1: Results when varying the rank to approximate our informative prior in Banana on the DecoyMNIST task. Results are averaged over 5 seeds, and the shaded region represents mean $\pm$ s.e.
Refer to caption: x5.png

### A.2 Varying the Complexity of Our Informative Prior Approximation

As demonstrated in Table 2, our approach can capture domain knowledge in the form of $\phi$ through a rank-$r$ approximation of the covariance matrix of a multivariate Gaussian distribution. Here, we run ablations to study how the rank of our approximation influences downstream performance, albeit while suffering slightly larger computational costs (i.e., $O(rn)$ where $r$ is the rank and $n$ is the number of parameters).

We observe that increasing the rank of our prior approximation on the DecoyMNIST task seems to slightly improve performance, with larger rank approximations plateuing in performance after $r=20$. (Figure A1). This slight increase demonstrates that learning informative priors with strong performance suffices with a small rank approximation, which is not too computationally expensive.

**Table A2: Comparison of Banana (with posterior averaging over logits) and a weaker version of Banana where we only learn the means and variance of a diagonalized Gaussian approximation of the informative prior. We compare against BNNs with isotropic Gaussian priors in terms of accuracy, AUROC, or $L_{1}$ loss and $\phi$ ($\pm$ s.e.) when averaged over 5 seeds. $\uparrow$ denotes a metric where higher is better, and $\downarrow$ denotes that lower is better. We bold either BNN or Banana when it achieves the best performance and the lowest value of $\phi$.**
|  | DecoyMNIST | MIMIC-IV | Pendulum |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| Method | Accuracy ($\uparrow$) | $\phi_{\text{background}}$ | AUROC ($\uparrow$) | $\phi_{\text{clinical}}$ | $L_{1}$ Loss ($\downarrow$) | $\phi_{\text{energy_damping}}$ |
| BNN | 76.41 $\pm$ 0.71 | 1.06 $\pm$ 0.06 | 0.6981 $\pm$ 0.0003 | 0.1624 $\pm$ 0.0005 | 0.0036 $\pm$ 0.0001 | 0.0319 $\pm$ 0.0026 |
| Banana (diag) | 76.52 $\pm$ 0.72 | 0.37 $\pm$ 0.01 | 0.6977 $\pm$ 0.0003 | 0.1628 $\pm$ 0.0012 | 0.0046 $\pm$ 0.0005 | 0.0170 $\pm$ 0.0050 |
| Banana | 78.21 $\pm$ 0.40 | 0.44 $\pm$ 0.01 | 0.6983 $\pm$ 0.0001 | 0.1619 $\pm$ 0.0005 | 0.0041 $\pm$ 0.0007 | 0.0025 $\pm$ 0.0010 |

We also provide additional experiments that use a diagonalized Gaussian approximation for this informative prior. Here, our learnable parameters are simply the means and a vector of variances along the diagonal of a diagonalized covariance matrix. We observe that this successfully captures some information from $\phi$, but our more complex approximation via a low-rank Gaussian performs better in capturing our domain knowledge. This demonstrates that indeed a sufficiently complex prior is required to gain the full benefits of using domain knowledge.

### A.3 Comparison against Other Prior Transfer Techniques

We provide comparisons against additional techniques to transfer the prior learned in Banana across different model architectures. We observe that MMD and 1st Moment Matching using SWAG [Maddox et al., ] perform favorably when compared to simply matching and directly optimizing over the learnable parameters of the prior approximation.

**Table A3: Comparing the value of $\phi$ of models drawn from an isotropic Gaussian prior and an informative prior transferred from Banana to a larger network size in terms of hidden dimension size via multiple moment matching techniques and MMD. Results are averaged over 5 seeds.**
| Method | DecoyMNIST | Folktables | MIMIC-IV | Pendulum |
| --- | --- | --- | --- | --- |
| Isotropic (L) | $0.4963\pm 0.0151$ | $0.0231\pm 0.0025$ | $0.2932\pm 0.0091$ | $179.6625\pm 15.9685$ |
| Banana + 1st Moment | $0.0288\pm 0.0045$ | $0.0111\pm 0.0049$ | $0.0034\pm 0.0026$ | $970.2352\pm 277.8245$ |
| Banana + 1st and 2nd Moment | $0.0291\pm 0.0016$ | $0.0218\pm 0.003$ | $0.0857\pm 0.024$ | $339.4531\pm 56.9897$ |
| Banana + MMD | $0.0288\pm 0.0044$ | $0.02\pm 0.0048$ | $0.004\pm 0.002$ | $0.0035\pm 0.0055$ |
| Banana + 1st Moment (SWAG) | $0.0015\pm 0.0005$ | $0.0014\pm 0.0021$ | $0.0\pm 0.0$ | $0.0\pm 0.0$ |

### A.4 Comparison against Frequentist Approaches

While not the main focus of our paper, we also provide a comparison against standard frequentist approaches to incorporate domain knowledge. We compare against a standard supervised learning approach and a Lagrangian-penalized approach, where we can directly regularize with the value of $\phi$ times some hyperparameter $\lambda$, as in Eq. (1). We also consider an ensemble of such Lagrangian-penalized methods, which we refer to as Lagrangian ensemble. We also remark that this would be similar to the performance of posterior regularization.

**Table A4: We compare Banana against frequentist analogues that incorporate domain knowledge and report the accuracy, AUROC, or $L_{1}$ loss and $\phi$ ($\pm$ s.e.) when averaged over 5 seeds.**
|  | DecoyMNIST | MIMIC-IV | Pendulum |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| Method | Accuracy ($\uparrow$) | $\phi_{\text{background}}$ | AUROC ($\uparrow$) | $\phi_{\text{clinical}}$ | $L_{1}$ Loss ($\downarrow$) | $\phi_{\text{energy_damping}}$ |
| Supervised | 70.54 $\pm$ 1.64 | 0.31 $\pm$ 0.08 | 0.6987 $\pm$ 0.0011 | 0.1697 $\pm$ 0.0131 | 0.150 $\pm$ 0.049 | 0.0083 $\pm$ 0.0026 |
| Lagrangian | 78.98 $\pm$ 1.39 | 0.13 $\pm$ 0.01 | 0.6993 $\pm$ 0.0026 | 0.1684 $\pm$ 0.0026 | 0.186 $\pm$ 0.058 | 0.0035 $\pm$ 0.0014 |
| Lagrangian Ens. | 81.80 $\pm$ 0.36 | 0.14 $\pm$ 0.01 | 0.6982 $\pm$ 0.0017 | 0.1623 $\pm$ 0.0027 | 0.00032 $\pm$ 0.00004 | 0.0043 $\pm$ 0.0007 |
| Banana | 78.21 $\pm$ 0.40 | 0.44 $\pm$ 0.01 | 0.6983 $\pm$ 0.0001 | 0.1619 $\pm$ 0.0005 | 0.0041 $\pm$ 0.0007 | 0.0025 $\pm$ 0.0010 |

In Table A4, we observe it seems more effective to directly regularize with $\phi$ in making the values of $\phi$ smaller. On the MIMIC dataset, we observe that all methods are comparable. This is likely due to the domain knowledge not being particularly helpful given the amount of labeled data (2000 examples); this is supported by the observation that the supervised and lagrangian methods have similar performance. However, we again note that performing Lagrangian ensembling methods are more computationally intensive, as it requires regularizing with $\phi$ during each model training process.

## B Experimental Details

##### Hyperparameters

We perform hyperparameter optimization over the following hyperparameter values, selecting the best-performing method on the validation set. For all methods, we consider two-layer neural networks with a ReLU activation function and a hidden dimension size $\in[8,16,32]$ for the Folktables dataset, $\in[8]$ for DecoyMNIST and Pendulum, and $\in[32,64,96]$ for MIMIC-IV. We also consider batch sizes in $[129,256,512]$ for Folktables, $[128,256]$ for DecoyMNIST and Pendulum, and $[128,256,512]$ for MIMIC-IV. We remark that on DecoyMNIST the value of gradients (with respect to input data) is quite sensitive to the overall scale of the for the learnable parameters of the informative prior in Banana.
Therefore, we use an initialization randomly sampled from $\mathcal{N}(0,0.01)$.
We also use a $N(0,0.01)$ initialization for Pendulum.
On other tasks, we simply initialize the parameters with $\mathcal{N}(0,1)$ as they are not as sensitive. For BNNs, we similarly consider a prior distribution of $\mathcal{N}(0,\sigma^{2}I)$, where $\sigma^{2}$ is a hyperparameter tuned on the validation set. For specific methods, we use the following hyperparameters.

##### Supervised and Lagrangian

- •
learning rate $\in[0.1,0.01,0.001,0.0001]$ on Folktables Pendulum and MIMIC; learning rate $\in[0.01,0.001,0.0001]$ on DecoyMNIST
- •
epochs $\in[10,20,30]$ on Folktables, Pendulum, and MIMIC; epochs $\in[10,15,20]$ on DecoyMNIST
- •
$\lambda\in[1,0.1,0.01,0.001]$ on Folktables, Pendulum, and MIMIC; $\lambda\in[0.001,0.0001]$ on DecoyMNIST
- •
weight decay $\in[0,0.01,0.1]$, usedin a standard $L_{2}$ penalization over network weights

##### BNN and Banana

- •
number of models (posterior samples) $=5$ on Folktables, Pendulum, and MIMIC; number of models $=3$ on DecoyMNIST
- •
pretraining epochs $\in[10,20,30]$
- •
posterior epochs $\in[30,40,50]$ in MIMIC; posterior epochs $\in[5,10]$ in DecoyMNIST; posterior epochs $\in[50,75,100]$ on Folktables; posterior epochs $\in[10,20,30]$ on Pendulum
- •
prior weight $\in[10^{-7},10^{-8},10^{-9},10^{-11}]$ on MNIST; prior weight $\in[10^{-7},10^{-9},10^{-11}]$ on Folktables; prior weight $\in[10^{-6},10^{-7},10^{-8}]$ on MIMIC; prior weight $\in[10^{-7},10^{-8},10^{-9}]$ on Pendulum
- •
$\tau=1$ for MIMIC; $\tau\in[0.001,0.0005,0.0001]$ for Pendulum; $\tau\in[10,1,0.1]$ for DecoyMNIST; $\tau\in[0.1,0.01,0.001]$ for Folktables
- •
$\beta\in[0.01,0.001,0.0001]$ for Folktables and DecoyMNIST; $\beta\in[0.1,0.01,0.001]$ for MIMIC; $\beta\in[0.01,0.001]$ for Pendulum
- •
low-rank approximation $r\in[20,30]$ for DecoyMNIST, Folktables, and MIMIC; $r\in[10,20]$ for Pendulum
- •
prior learning rate $\in[0.1,0.01]$ on Folktables and Pendulum; prior learning rate $\in[0.01,0.001,0.0001]$ on DecoyMNIST; prior learning rate $\in[0.01,0.001]$ on MIMIC
- •
posterior learning rate $\in[0.5,0.1,0.01]$ on Folktables; posterior learning rate $\in[0.01,0.005,0.001]$ for Pendulum; posterior learning rate $\in[0.01,0.001,0.0001]$ for DecoyMNIST; posterior learning rate $\in[0.5,0.3,0.1]$ for MIMIC
- •
$\sigma^{2}\in[0.01,0.1,1]$ for DecoyMNIST; $\sigma^{2}=1$ for Folktables, Pendulum, and ACS

##### Compute Resources

Each experiment was run on a single GeForce 2080 Ti GPU.

## C Dataset Details

### C.1 Details on Folktables

We use the Folktables dataset for the task of determining the employment of a particular job applicant. We restrict our focus to the Alabama subset of the data from 2018. We refer readers to [Ding et al., ] for more specific details about the dataset and its collection.

### C.2 Details on Pendulum Dataset

On the Pendulum dataset [Seo et al., ], we use the configuration detailed in Table C1 for generating the time-series data. We refer the readers to Seo et al. [] for full details on the dataset.

**Table C1: Constants used in the generation of the Pendulum dataset.**
| Dataset Configuration | Value |
| --- | --- |
| String 1 Length | 1 |
| String 2 Length | 1 |
| Mass 1 | 1 |
| Mass 2 | 5 |
| Friction Coefficient 1 | 0.001 |
| Friction Coefficient 2 | 0.001 |

### C.3 Details on Healthcare Data

MIMIC-IV [Johnson et al., ] is an open-access database that consists of deidentified electronic health record data collected at the Beth Israel Deaconness Medical Center between years 2008 and 2019, covering over 400,000 distinct hospital admissions. For the intervention prediction task described in Section 5.1, we focus on admissions that include a stay in the intensive care unit (ICU), for which various physiological measurements from bedside monitors, lab tests, etc. are readily available at higher temporal resolution. We provide details on how the study cohort was selected for the experiments, how the features and labels were extracted, and a demographics summary of the final resulting cohort.

##### Cohort Selection.

For our study cohort, we include all ICU stays that satisfy the following criteria:

- •
Adult patients: Given that physiology of young children and adolescents can differ significantly from that of adults, we only include ICU stays corresponding to adult patients between the age of 18 and 89 at the time of admission.
- •
First ICU stay: Following standard practice [Wang et al., ], if a patient has multiple ICU stays recorded in the database across all hospitalizations, we only include the first ICU stay.
- •
Length of ICU stay $\geq$ 48 hours: We only include ICU stays that lasted long enough to have a sufficient number of measurements for every stay and remove outlier cases.

We note that not all ICU stays selected by this inclusion criteria are eventually included, due to the additional filtering steps detailed in the description on feature and label extraction below. We include a summary of demographic information for the final extracted cohort in Table C2.

**Table C2: Summary of demographics for the final extracted cohort of ICU patients. Except for the total number of ICU patients included, we report the mean and standard deviation (in parentheses) of each demographic feature.**
|  |  | Missing | Overall |
| --- | --- | --- | --- |
| Number of ICU Patients |  |  | 13944 |
| Age |  | 0 | 64.3 (15.7) |
| Gender | Female | 0 | 5751 (41.2) |
|  | Male |  | 8193 (58.8) |
| Ethnicity | Asian | 0 | 394 (2.8) |
|  | Black |  | 1464 (10.5) |
|  | Hispanic |  | 525 (3.8) |
|  | Native American |  | 57 (0.4) |
|  | Other/Unknown |  | 2451 (17.6) |
|  | White |  | 9053 (64.9) |
| Admission Height |  | 3843 | 169.7 (10.5) |
| Admission Weight |  | 0 | 84.0 (25.1) |
| Length of Stay |  | 0 | 185.5 (185.4) |
| ICU Type | Cardiac Vascular Intensive Care Unit (CVICU) | 0 | 2317 (16.6) |
|  | Coronary Care Unit (CCU) |  | 1625 (11.7) |
|  | Medical Intensive Care Unit (MICU) |  | 3432 (24.6) |
|  | Medical/Surgical Intensive Care Unit (MICU/SICU) |  | 2237 (16.0) |
|  | Neuro Intermediate |  | 44 (0.3) |
|  | Neuro Stepdown |  | 16 (0.1) |
|  | Neuro Surgical Intensive Care Unit (Neuro SICU) |  | 386 (2.8) |
|  | Surgical Intensive Care Unit (SICU) |  | 1933 (13.9) |
|  | Trauma SICU (TSICU) |  | 1954 (14.0) |

##### Feature and Label Extraction.

For all ICU stays included in the cohort, we extract the same set of features (2 static and 6 time-dependent features) used in Yang et al. [], listed below.

- •
Mean Arterial Pressure (MAP): Time-Dependent
- •
Age at Admission: Static
- •
Urine Output: Time-Dependent
- •
Weight at Admission: Static
- •
Creatinine: Time-Dependent
- •
Lactate: Time-Dependent
- •
Bicarbonate: Time-Dependent
- •
Blood Urea Nitrogen (BUN): Time-Dependent

Every recorded time-dependent feature has an associated time stamp (e.g., 2180-07-23 23:50:47), and we use the measurement time offset from the start time of the corresponding ICU stay to aggregate all measurements into hourly bins and obtain a discretized time-series representation. Within each hourly bin, if more than one measurements are available, we take the most recent measurement. For the static features, we duplicate them along all hourly bins. For example, suppose that a patient’s first ICU stay lasted for 2 days. We then obtain a $48\times 8$ time-series representation, where the rows correspond to the 48 hourly bins, and the columns correspond to the 6 time-dependent features and the 2 static features duplicated along all rows.

As in Yang et al. [], we consider a time-independent binary classification task, where we treat the 8-dimensional features at each hourly bin as a separate sample and predict whether an intervention for hypotension management is necessary for the given hour. To obtain the hourly labels to predict, we extract the start and end times of all recorded vasopressor (e.g., norepinephrine, dobutamine) administrations for each ICU stay, and label each hourly bin as 1 if the vasopressor duration coincides with the hourly bin.

Additionally, given that clinical measurements are measured at different intervals and high levels of sparsity, we filter out all rows that have missing features. Concatenating all samples together, we obtain input features $X\in\mathbb{R}^{49953\times 8}$ and labels $Y\in\{0,1\}^{49953}$, where the labels are approximately balanced (positive: 25171 samples, negative: 23565 samples). We then take a stratified 70-15-15 split to get the training, validation, and test datasets while preserving the label proportions, and standardizing all features to zero mean and unit variance based on the training data. We also note that we take a subset of the training data when used to compare all of our approaches; we use a total of 2000 examples.

##### Thresholds Used for Defining ϕ clinical subscript italic-ϕ clinical \phi_{\text{clinical}} italic_ϕ start_POSTSUBSCRIPT clinical end_POSTSUBSCRIPT .

In adults, the normal range for lactate levels are $0.5$–$2.2$ mmol/L(^*^**[https://www.ucsfhealth.org/medical-tests/lactic-acid-test](https://www.ucsfhealth.org/medical-tests/lactic-acid-test)) and bicarbonate levels are $22$–$32$ mmol/L(^*^**[https://myhealth.ucsd.edu/Library/Encyclopedia/167,bicarbonate](https://myhealth.ucsd.edu/Library/Encyclopedia/167,bicarbonate)), and we therefore define the thresholds $\tilde{x}_{\text{lactate}}=2.2$ and $\tilde{x}_{\text{bicarbonate}}=22$ and standardize these values according to the training data.

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: Please see the above section.
soundness: 2
strengths: The manuscript tries to address the important topic of informative priors for efficiently modeling Bayesian inference to incorporate domain knowledge.
summary: This paper proposes a approach for incorporating domain knowledge into priors for Bayesian neural networks (BNNs). 
The domain knowledge is represented as a loss function phi that measures how well a model aligns with the given knowledge. Using variational inference phi is used to reweight the prior distribution over neural network weights.
weaknesses: - The theoretical justification for phi loss incorporating domain knowledge is not clear; this proposed formulation resembles an empirical Bayes setup where informative priors are learned from the data.
- There is a large body of work on informative priors that considers techniques such as empirical Bayes and hierarchical Bayes to incorporate domain knowledge.
- In the results section, it is unclear why the comparison of phi values against the selected datasets indicates the incorporation of domain knowledge.
- It is unclear how to interpret whether the model has successfully incorporated domain knowledge in a Bayesian setting without comparing standard uncertainty quantification metrics.
- While the method claims low complexity, it involves learning an informative prior through variational inference, which may add computational overhead compared to using standard uninformative priors. The paper does not discuss the computational costs, aside from a brief mention in the Appendix.
- The selected problems involve very small datasets (<50 samples) and toy problems, but practical examples with approximately 1,000 samples are needed to demonstrate effectiveness.

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 2
questions: * How are the variational parameters of the BNN initialized? Does initialization of the variational posterior q(w) play a role in addressing the domain knowledge awareness, or specifying the prior p(w) is sufficient? 

* The results of Folktables dataset are presented in the transferrinf priors experiments in Table 2. Any reason for not providing the results of this dataset in Table 1?

* Can the authors clarify their motivation for choosing the specific datasets used in the experiments?
soundness: 2
strengths: * The paper is well-motivated to specify informed priors in BNNs that reflects the relevant domain knowledge and mitigate undesirable biases.

* The proposed framework enables the integration of generic forms of domain knowledge such as physics rules, fairness, healthcare knowledge into BNN prior, and also proposes strategy to transfer the priors to other models without the need to relearn a new prior every time.
summary: This paper proposes a framework for incorporating general form of domain knowledge into Bayesian neural network (BNN) through learned informative priors. These domain knowledge priors are specified via loss functions that measures the alignment of a particular model to the desired domain knowledge, and learned through variational inference. Empirical evaluation is performed using Stochastic Gradient Langevin Dynamics (SGLD) as the baseline with experiments on a 2-layer feedforward neural network, demonstrating the model with domain knowledge priors achieves better predictive performance than BNNs with commonly used priors (such as isotropic, Gaussian).
weaknesses: * One of the main objective of Bayesian neural network (BNN) is uncertainty quantification (UQ) in their predictions. However, this paper does not address the ability of BNNs to reliably quantify model uncertainty in the study and experimental evaluation. The experiments conducted in the study are limited to evaluating predictive accuracy and domain knowledge surrogate loss, neglecting the critical UQ aspect of BNNs. This raises concerns about the evaluation of BNNs with the proposed informed prior, and the reliability of the model's uncertainty estimates, which are essential. I encourage the authors to include a study evaluating the quality of model uncertainty estimates using commonly used metrics such as Expected Calibration Error, AUROC for out-of-distribution detection etc.

* The paper claims to propose a strategy for transferring learned informative priors across different neural network architectures. However, the experiments conducted to validate this claim are limited to transferring priors between two 2-layer feed forward neural networks with different hidden dimension sizes. This raises concerns about the generalizability of the proposed strategy to significantly different architectures, such as Convolutional Neural Networks (CNNs) or other architectures used in the Bayesian deep learning literature. I encourage the authors to evaluate transferring learned priors between MLPs and CNNs, or vice-versa.

* The lack of experimentation with a broader range of neural network architectures beyond a small 2-layer feedforward model leaves open questions about the effectiveness of the proposed method to other model architectures and it's scalability to larger models. Also, the motivation for the choice of datasets used in the empirical experiments is not clear. The datasets selected are uncommon in the Bayesian deep learning literature, which makes it difficult to compare the results with existing studies and to assess the relevance and robustness of the proposed method.

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: Please see weaknesses section above.
soundness: 3
strengths: - The paper is well-motivated, and the approach is clean. Incorporating domain knowledge into informative priors is an interesting direction for Bayesian deep learning.
- The paper proposes four general domain knowledge losses that supplement the available training data in meaningful ways.
- The paper demonstrates that the learned prior is better aligned with domain knowledge and often improves predictive performance compared to standard priors.
summary: This paper proposes a framework for integrating domain knowledge into a prior over neural network weights. It uses variational inference to learn a low-rank Gaussian prior in weight space, guided by a domain knowledge loss that depends only on input data. The paper proposes four practical losses that incorporate different types of domain knowledge. It also proposes methods for transferring priors between different architectures.
weaknesses: - My main concern is that I'm not convinced that the best way to use the proposed domain knowledge losses is to learn a prior over weights upfront. As the paper states in page 4, we could also use these losses to regularize the training process. You could similarly train a BNN with a likelihood function that incorporates these losses. Could the authors explain why learning a prior is better than these alternatives? Section A.5 empirically compares this alternative somewhat. Still, I think a more thorough comparison would be to do a wide sweep over values of the regularization coefficient and report (performance, domain loss) for each.
- The paper mentions uncertainty as a primary motivation for using BNNs (abstract, intro, ...), but the evaluation does not measure uncertainty; this is important since the prior learned by Banana may improve performance over standard priors at the cost of worse uncertainty estimation.
- Fairness loss involves subgroup information, which is known to significantly improve fairness metrics when used during training [1]. For the experiment on Folktables, I think the comparison to the baseline is not entirely fair because the baseline doesn't have access to the subgroup information.

[1] Sagawa, Shiori, et al. "Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization." arXiv preprint arXiv:1911.08731 (2019).

Minor comment:
- (just out of curiosity) Is Banana an acronym for something?

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 3
questions: I appreciate for authors to conduct a good study on an intriguing topic. I have a few questions after reading this paper.

**[Q1]** What value was used for the rank $r$ in the experiments?


**[Q2]** In Figure 3, when $K = 10$, the performance is the best, then declines, and eventually rises again. What do you think causes this phenomenon?


**[Q3]** In Section 5.3, I understood that a multi-modal distribution was used to represent a complex distribution. However, I believe that the proposed methodology for learning a general informative prior is inherently complex (as shown in Figure 2). Therefore, I’m having difficulty understanding how this experiment supports the proposed methodology. Could you please explain this in more detail? If I misunderstood this section, I would appreciate any additional clarification.
soundness: 2
strengths: **[S1]** The idea of incorporating general forms of domain knowledge into prior via loss function is interesting.

**[S2]** It is novel and compelling approach transferring learned priors across different model architectures.

**[S3]** The experimental results support that the proposed methodology effectively learns prior.
summary: This work presents framework to learn prior that integrates domain knowledge in BNN. In detail, it expresses domain knowledge as a loss function and optimize the variational objective. It also suggests transferring learned priors between different model architectures, based on Moment Matching and Maximum Mean Discrepancy.
weaknesses: I believe the proposed methods are solid, but there is chance to elevate the persuasive strength with experiments.



**[W1]** All experiments were conducted on a 2-layer MLP model. Performances on larger model would give more credibility to the paper. Specifically, while it may be challenging to evaluate performance on ViT, assessing this methodology’s impact on models like ResNet would further validate its potential for performance enhancement.



**[W2]** Experiments on a larger dataset seem necessary. Although increasing the data volume reduces the influence of the prior, making it difficult to evaluate the effect of the learned prior using the proposed method, the machine learning and deep learning communities widely accept the use of larger models and datasets. The paper's contribution can further be amplified by demonstrating that this methodology remains effective under larger dataset.



**[W3]** The paper lacks recent baselines. For prior-related baselines, it employs isotropic Gaussian, Gaussian optimized via Laplace, and GP prior. However, the informative prior method *Pre-train Your Loss* [1], a significant advancement in this area, should definitely be included.



**[W4]** The writing (notations) could also be improved.

- $x_{i}^{\prime}$ is not defined before Equation (1).
- I believe that $X^\prime = \{ x_1, ..., x_m\}$ in line 283-284 can be clear by rewriting as $X^\prime = \{ x_1^\prime, ..., x_m^\prime\}$



---
[1] Ravid Shwartz-Ziv, Micah Goldblum, Hossein Souri, Sanyam Kapoor, Chen Zhu, Yann LeCun, and Andrew G Wilson. Pre-Train Your Loss: Easy Bayesian Transfer Learning with Informative Priors. Advances in Neural Information Processing Systems, 2022.

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 3
questions: See Weaknesses section.
soundness: 3
strengths: Strengths

- The paper is well-written and easy to follow.
- Research that enables the efficient learning of human inductive biases or specific constraints in the form of a prior distribution is valuable, and the potential to create priors containing diverse information, such as fairness, is an interesting aspect of this work.
summary: This paper introduces a method for learning an informative prior through variational inference, as an alternative to the commonly used uninformative Gaussian prior distribution in Bayesian Neural Networks (BNNs). And, it proposes a technique for incorporating various inductive biases—difficult to represent with traditional methods—by converting them into a loss form that can be learned as a prior.
weaknesses: Weaknesses

- In Section 4, it’s unclear why the authors use $\phi$ as the likelihood when calculating the posterior distribution, rather than directly calculating a posterior that reflects this loss. Instead, they create a prior distribution first and then sample from the posterior using SGMCMC methods. This two-stage sampling approach seems likely to reduce computational efficiency significantly.
  
- Another drawback is that everything must be represented in the form of a loss. This loss-based formulation can already be interpreted as a regularization term on the likelihood or as a prior distribution in standard MAP solutions or posterior sampling methods, which raises questions about whether this approach is truly novel.

- In addition to [1], which the paper mentions as related work, other studies such as [2] and [3] have also explored methods for creating informative prior distributions. Adding these to the related work section would strengthen the context.

- A key and critical point that prevents me from leaning toward acceptance is that the experiments were conducted only on a simple 2-layer MLP. As model and data scales increase, various methods can behave quite differently, and the experiment on such a limited model scale does not demonstrate that the proposed prior distribution can be effectively applied to larger models.

- The baseline should also include methods like [1] and [2]. Similar to how the authors pre-trained the model using unlabeled data to learn a prior distribution, [1] and [2] also use self-supervised learning to pre-train models, which can then be employed as informative priors.

- To ensure that the proposed method can be safely used for posterior sampling or learning, we need to examine whether it experiences severe performance degradation or operates with a degree of robustness in cases where the inductive bias is incorrect, leading to a misspecified prior distribution, i.e., under model-data misspecification conditions.

References

[1] Shwartz-Ziv, R., Goldblum, M., Souri, H., Kapoor, S., Zhu, C., LeCun, Y., & Wilson, A. G. (2022). Pre-train your loss: Easy bayesian transfer learning with informative priors. Advances in Neural Information Processing Systems, 35, 27706-27715.

[2] Lee, H., Nam, G., Fong, E., & Lee, J. Enhancing Transfer Learning with Flexible Nonparametric Posterior Sampling. In The Twelfth International Conference on Learning Representations.

[3] Lim, S., Yeom, J., Kim, S., Byun, H., Kang, J., Jung, Y., ... & Song, K. (2024). Flat Posterior Does Matter For Bayesian Transfer Learning. arXiv preprint arXiv:2406.15664.

Meta-review: The paper presents a novel approach to incorporating domain knowledge into the prior distribution of Bayesian Neural Networks (BNNs) through variational inference, which can be used to encode various inductive biases, such as fairness and physics-based rules. While the reviewers found the paper to be well-written and the approach to be interesting and novel, they raised several concerns, including the lack of experiments on larger models and datasets, the need for more comparisons to recent baselines, and the potential limitations of the loss-based formulation. However, the authors effectively addressed these concerns by providing additional experiments, including comparisons to recent baselines, such as Pretrain Your Loss, and experiments on larger models, including a ResNet-18 architecture on the Waterbirds dataset, which demonstrated the effectiveness of their approach in incorporating domain knowledge and improving model performance, particularly in terms of fairness and worst-group accuracy. Overall, the authors' responses and additional experiments have clearly strengthened the paper. However, after discussion with the authors and among themselves, the reviewers find the paper to still be very borderline, with two reviewers leaning towards acceptance and three towards rejection. We will therefore need to reject the paper in its current form. We would still like to encourage the authors to resubmit an improved version of the paper in the future.

Decision: Reject