arXiv is now an independent nonprofit! Learn more
License: arXiv.org perpetual non-exclusive license
arXiv:1507.05331v1 [stat.ML] 19 Jul 2015

Fast Adaptive Weight Noise

Justin Bayer    Maximilian Karl    Daniela Korhammer Affiliation: Technische Universität München    Patrick van der Smagt Affiliation: Technische Universität München Affiliation: and fortiss, TUM Associate Institute Affiliation: bayer.justin@googlemail.com, karlma@in.tum.de Affiliation: korhammd@in.tum.de, smagt@brml.org
Abstract

Marginalising out uncertain quantities within the internal representations or parameters of neural networks is of central importance for a wide range of learning techniques, such as empirical, variational or full Bayesian methods. We set out to generalise fast dropout (Wang & Manning, 2013) to cover a wider variety of noise processes in neural networks. This leads to an efficient calculation of the marginal likelihood and predictive distribution which evades sampling and the consequential increase in training time due to highly variant gradient estimates. This allows us to approximate variational Bayes for the parameters of feed-forward neural networks. Inspired by the minimum description length principle, we also propose and experimentally verify the direct optimisation of the regularised predictive distribution. The methods yield results competitive with previous neural network based approaches and Gaussian processes on a wide range of regression tasks.

   

1 Introduction

Deep learning methods have started to become practical for a wide range of tasks where very many labeled examples for supervised training are available, especially in the domains of sensory processing (e.g., vision or audio tasks). Yet, methods which work well on data sets with few training cases in the context of regression of continuous quantities remain scarce. Frequentist schemes such as weight decay or heuristics such as dropout have so far not been able to deliver significant improvements over methods not stemming from the connectionist paradigm, such as Gaussian processes or random forests; consequently, deep learning methods are generally not considered in fields where learning should be realised on small data sets.

We consider neural networks with parameters θ\theta as weights and biases. If we treat the parameters θ\theta not as points, but summarise our belief about them via a distribution q(θ)q(\theta), the data is explained by marginalising out that distribution, i.e.

p(𝒟train)\displaystyle p(\mathcal{D}_{\text{train}}) =θp(𝒟train|θ)q(θ)𝑑θ.\displaystyle=\int_{\theta}p(\mathcal{D}_{\text{train}}|\theta)q(\theta)d\theta. (1)

In the case of p(θ)=q(θ)p(\theta)=q(\theta), i.e. qq is a prior, this is commonly referenced to as the marginal likelihood. We will consider supervised data only, that is 𝒟train={(𝐱i,𝐳i)}i=1N\mathcal{D}_{\text{train}}=\{({}^{i}\mathbf{x},{}^{i}\mathbf{z})\}_{i=1}^{N} where the functional relationship 𝐱𝐳\mathbf{x}\rightarrow\mathbf{z} is of interest. In Bayesian learning, a prior p(θ)p(\theta) is used for qq to obtain a posterior via Bayes’ rule

p(θ|𝒟train)\displaystyle p(\theta|\mathcal{D}_{\text{train}}) =p(θ)p(𝒟train|θ)p(𝒟train),\displaystyle={p(\theta)p(\mathcal{D}_{\text{train}}|\theta)\over p(\mathcal{D}_{\text{train}})}, (2)

which can then be used to form a predictive distribution for unseen data points

p(𝐳|𝐱,𝒟train)\displaystyle p(\mathbf{z}|\mathbf{x},\mathcal{D}_{\text{train}}) =θp(𝐳|𝐱,θ)p(θ|𝒟train)𝑑θ.\displaystyle=\int_{\theta}p(\mathbf{z}|\mathbf{x},\theta)\,p(\theta|\mathcal{D}_{\text{train}})\,d\theta. (3)

In practice, Bayesian models are designed in a hierarchical way, where the prior is specified with the help of an additional hyperprior, i.e., p(θ)=ηp(θ|η)p(η)p(\theta)=\int_{\eta}p(\theta|\eta)p(\eta).

In all but the most trivial cases, Bayesian learning comes with several difficulties which require approximations. For neural networks, not only will the posterior p(θ|𝒟train)p(\theta|\mathcal{D}_{\text{train}}) be highly multimodal due to symmetries in the weight space, but it will also be intractable to find the normalisation constant p(𝒟train)=p(𝒟train|θ)p(θ)𝑑θp(\mathcal{D}_{\text{train}})=\int p(\mathcal{D}_{\text{train}}|\theta)p(\theta)d\theta, i.e., the marginal likelihood.

Due to this intractability for all but the simplest cases, neural network practitioners have to resort to approximation schemes such as sampling (e.g., via Markov chain Monte Carlo Neal (1993)), variational inference (Hinton & Van Camp, 1993), combinations thereof (Graves, 2011), or Gaussian approximations (MacKay, 1992).

The contributions of this work will be as follows. We will extend the idea of fast dropout (Wang & Manning, 2013) to the marginalisation of distributions over the weights of a neural network in Section 2, and introduce an efficient way to respect the correlations between outputs units in Section 3.1. This will be used to perform variational Bayes for the special case of a Gaussian likelihood function in Section 3.3. In Section 3.4 we will then propose a novel method to find a distribution over weights, namely the minimisation of the negative log-likelihood of the data plus a regularisation term. The proposed methods will be verified experimentally in Section 4. We model the distributions over weights using diagonal Gaussian as well as Bernoulli distributions.

1.1 Related Work

The idea to treat weights in a neural network in a stochastic way, i.e. impose a distribution on them, goes back at least to Buntine & Weigend (1991). Albeit dated, MacKay (1995) is an excellent survey article on probabilistically motivated approaches to neural networks, containing many concepts and ideas from the literature. Using sampling-based techniques, Graves (2011) develops a practical algorithm based on VI (VI). More recently, Hernández-Lobato & Adams (2015) developed a method to treat units in neural networks in terms of their first two moments; they also develop a novel Bayesian learning algorithm for such scenarios. Most relevant to this section are the results from Wang & Manning (2013)—in fact, their work served as a starting point for this paper. Even more recently Blundell et al. (2015) used stochastic weights and an objective function using the variational free energy. They used the reparametrisation trick from Kingma & Welling (2013) to backpropagate through the sampling process itself. Most close to our work is the independently developed method by Kingma et al. (2015), who use fast dropout-like calculations to reduce the sampling effort and variance of the gradient estimators.

2 Variance Propagation

2.1 Propagation of Variance through a Transformation

We are using Variance Propagation to compute the effect of marginalising out the weight distribution. This variance propagation is based on the works of Wang & Manning (2013), where it was shown for the case of 𝐱~=𝐱𝐦\tilde{\mathbf{x}}=\mathbf{x}\cdot\mathbf{m} where mi(d)m_{i}\sim\mathcal{B}(d) follows a Bernoulli distribution with rate dd. Here, 𝐱~\tilde{\mathbf{x}} is the input to the model corrupted by “dropout” noise.

Wang & Manning (2013) provides a set of rules for propagation of mean and variance through a network. Rules for multiplication and addition are defined by elementary facts of probability (Grimmett & Stirzaker, 1992).

2.1.1 Propagation of Variance through a Linear Transformation

We have a linear transformation a=𝐰~T𝐱~+b~a=\tilde{\mathbf{w}}^{T}\tilde{\mathbf{x}}+\tilde{b}. If 𝐰~,𝐱~\tilde{\mathbf{w}},\tilde{\mathbf{x}} and b~\tilde{b} are independent of each other, have sufficiently many components and finite mean and variance, the central limit theorem (Grimmett & Stirzaker, 1992) applies. This makes aa distributed approximately according to a Gaussian, i.e. a𝒩(E[a],V[a])a\sim\mathcal{N}(\text{E}\left[a\right],\text{V}[a]). More specifically, consider a distribution q(θ~)q(\tilde{\theta}) over the parameters of the model with θ~={𝐰~,b~}\tilde{\theta}=\{\tilde{\mathbf{w}},\tilde{b}\}.

We obtain an approximation of the marginal likelihood (cf. Equation 1):

p(a|𝐱)\displaystyle p(a|\mathbf{x}) =θ~q(θ~)p(a|𝐱,θ~)𝑑θ~\displaystyle=\int_{\tilde{\theta}}q(\tilde{\theta})p(a|\mathbf{x},\tilde{\theta})d\tilde{\theta} (4)
𝒩(E[a],V[a]).\displaystyle\approx\mathcal{N}(\text{E}\left[a\right],\text{V}[a]).

All that is left to determine is then the expectation and variance of aa. Since both are sums and/or products of quantities with known expectation and variance, the calculations are given by

E[a]=\displaystyle\text{E}\left[a\right]= E[𝐰~]TE[𝐱~]+E[b~],\displaystyle\text{E}\left[\tilde{\mathbf{w}}\right]^{T}\text{E}\left[\tilde{\mathbf{x}}\right]+\text{E}\left[\tilde{b}\right], (5)
V[a]=\displaystyle\text{V}[a]= V[b~]+V[𝐰~]TE[𝐱~]2+V[𝐱~]TE[𝐰~]2+V[𝐱~]TV[𝐰~],\displaystyle\text{V}[\tilde{b}]+\text{V}[\tilde{\mathbf{w}}]^{T}\text{E}\left[\tilde{\mathbf{x}}\right]^{2}+\text{V}[\tilde{\mathbf{x}}]^{T}\text{E}\left[\tilde{\mathbf{w}}\right]^{2}+\text{V}[\tilde{\mathbf{x}}]^{T}\text{V}[\tilde{\mathbf{w}}], (6)

where we have assumed once again that all components of 𝐱~,b~\tilde{\mathbf{x}},\tilde{b} and 𝐰~\tilde{\mathbf{w}} are independent.

2.1.2 Propagation of Variance through a Non-linear Function

While the propagation through transfer functions is not in general tractable, the fact that the integral is one-dimensional allows for a wide range of approximations. The most straightforward is the use of a table. Other options include Monte Carlo integration and the unscented transform (Julier & Uhlmann, 1997). For the rectifier transfer and the logistic sigmoid function, a closed form and a very good approximation are available, respectively. We present one of them here for the sake of completeness, but refer the interested reader to the corresponding paper by Wang & Manning (2013) for derivations.

In the case of the rectifier f(a)=max(a,0)=yf(a)=\text{max}(a,0)=y, we have:

r=\displaystyle r= E[a]V[a],\displaystyle{\text{E}\left[a\right]\over\sqrt{\text{V}[a]}},
E[y]=\displaystyle\text{E}\left[y\right]= Φ(r)E[a]+ϕ(r)V[a],\displaystyle\Phi(r)\text{E}\left[a\right]+\phi(r)\sqrt{\text{V}[a]},
V[y]=\displaystyle\text{V}[y]= E[a]V[a]ϕ(r)+(E[a]2+V[a])Φ(r)E[a]2\displaystyle\text{E}\left[a\right]\sqrt{\text{V}[a]}\phi(r)+\bigl(\text{E}\left[a\right]^{2}+\text{V}[a]\bigr)\Phi(r)-\text{E}\left[a\right]^{2}

where Φ(ξ)\Phi(\xi) and ϕ(ξ)\phi(\xi) are the cumulative distribution function and probability density function of the standard Normal, respectively.

We want to stress the fact that propagating 𝐚\mathbf{a} through the transfer function by integrating over each of its components aia_{i} separately will introduce the assumption that all elements of 𝐚\mathbf{a} are statistically independent, which is certainly not completely justified.

2.2 Variance Propagation for Deep Networks

In the previous section we described how to obtain the output expectation and variance of linear and non-linear transformations given the expectations and variances of its inputs. Deep networks can be constructed by stacking many of these on top of each other. We apply these methods to multilayer perceptron networks with additional noise processes affecting the weights of the network.

It should be noted that all operations are differentiable and thus gradient-based optimisation can be used. However, the equations are rather complex and use of an automatic differentiation tool such as Theano (Bergstra et al., 2010) is advisable.

2.3 Noise Processes

We now consider that the quantities 𝐰~,𝐱~,b~\tilde{\mathbf{w}},\tilde{\mathbf{x}},\tilde{b} are corrupted versions of the true underlying quantities 𝐰,𝐱,b\mathbf{w},\mathbf{x},b. We will focus on 𝐱~\tilde{\mathbf{x}} first, while the discussion is equivalent for 𝐰~\tilde{\mathbf{w}} and b~\tilde{b}. We define a noise process to be a probability distribution over possible corruptions given a clean input, i.e. c(𝐱~|𝐱)c(\tilde{\mathbf{x}}|\mathbf{x}). If we can obtain E[𝐱~]\text{E}\left[\tilde{\mathbf{x}}\right] and V[𝐱~]\text{V}[\tilde{\mathbf{x}}] given E[𝐱],V[𝐱]\text{E}\left[\mathbf{x}\right],\text{V}[\mathbf{x}] and cc, we can integrate cc seamlessly into the calculations.

Since we already gave the respective rules above, two obvious choices are additive and multiplicative noise. Given a vector of independent noise variables ϵ\boldsymbol{\epsilon} with known expectation and covariance, let 𝐱~=𝐱+ϵ\tilde{\mathbf{x}}=\mathbf{x}+\boldsymbol{\epsilon}, then

E[𝐱~]\displaystyle\text{E}\left[\tilde{\mathbf{x}}\right] =E[𝐱]+E[ϵ],\displaystyle=\text{E}\left[\mathbf{x}\right]+\text{E}\left[\boldsymbol{\epsilon}\right],
V[𝐱~]\displaystyle\text{V}[\tilde{\mathbf{x}}] =V[𝐱]+V[ϵ].\displaystyle=\text{V}[\mathbf{x}]+\text{V}[\boldsymbol{\epsilon}].

Analogously, if 𝐱~=𝐱ϵ\tilde{\mathbf{x}}=\mathbf{x}\cdot\boldsymbol{\epsilon},

E[𝐱~]\displaystyle\text{E}\left[\tilde{\mathbf{x}}\right] =E[𝐱]E[ϵ],\displaystyle=\text{E}\left[\mathbf{x}\right]\cdot\text{E}\left[\boldsymbol{\epsilon}\right],
V[𝐱~]\displaystyle\text{V}[\tilde{\mathbf{x}}] =E[𝐱]2V[ϵ]+V[𝐱]E[ϵ]2+V[𝐱]V[ϵ].\displaystyle=\text{E}\left[\mathbf{x}\right]^{2}\text{V}[\boldsymbol{\epsilon}]+\text{V}[\mathbf{x}]\text{E}\left[\boldsymbol{\epsilon}\right]^{2}+\text{V}[\mathbf{x}]\text{V}[\boldsymbol{\epsilon}].

Depending on the exact nature of ϵ\boldsymbol{\epsilon}, several noise injecting regularisers can be approximated, such as Dropout (Hinton et al., 2012) (as done by Wang & Manning (2013)), DropConnect (Wan et al., 2013) or Gaussian weight noise (Graves, 2013).

2.4 Soundness of the Approximation

Wang & Manning (2013) verified experimentally that the central limit theorem holds for deep neural networks in certain cases. This is, however, not possible in general and might fail in cases where inputs are low-dimensional or sparse. But is this at all important? Considering that we are only interested in a function approximator, the exact interpretations of different quantities in the network are unimportant. Loosely speaking, we do not care whether our model constitutes a good approximation of a corresponding real model, as long as the model works well enough for the task at hand, as indicated by an estimate of the generalisation error.

3 Fast Adaptive Weight Noise

Adaptive weight noise is a practical method to perform VB (VB) in neural networks (Graves, 2011). The method is based on the approach of Hinton & Van Camp (1993), who utilise the MDL (MDL) principle (Rissanen, 1985; Grünwald, 2007) as an inductive bias.

As usual in the Bayesian setting, the parameters of the model under consideration are not found via point estimates, but represented as a distribution over the weight space. Here, each parameter θi\theta_{i} will be represented by a Gaussian, i.e. q(θi)=𝒩(μi,σi2)q(\theta_{i})=\mathcal{N}(\mu_{i},\sigma^{2}_{i}).

If we are given a likelihood function and we consider qq as a variational approximation to the true posterior over the parameters having seen the data, the training criterion can be derived by means of VI:

vi:=\displaystyle\mathcal{L}_{\text{vi}}:= iθq(θ)logp(𝐳i|𝐱i,θ)dθ+𝕂𝕃[q(θ)||p(θ)]\displaystyle-\sum_{i}\int_{\theta}q(\theta)\log p({}^{i}\mathbf{z}|{}^{i}\mathbf{x},\theta)d\theta+\mathbb{KL}[q(\theta)||p(\theta)] (7)
=\displaystyle= iE[logp(𝐳i|𝐱i,θ)]θq+𝕂𝕃[q(θ)||p(θ)]\displaystyle-\sum_{i}\text{E}\left[\log p({}^{i}\mathbf{z}|{}^{i}\mathbf{x},\theta)\right]_{\theta\sim q}+\mathbb{KL}[q(\theta)||p(\theta)]
\displaystyle\approx 1Sis=1Slogp(𝐳i|𝐱i,θs)+𝕂𝕃[q(θ)||p(θ)],\displaystyle-{1\over S}\sum_{i}\sum_{s=1}^{S}\log p({}^{i}\mathbf{z}|{}^{i}\mathbf{x},\theta_{s})+\mathbb{KL}[q(\theta)||p(\theta)], θsq(θ)\displaystyle~\theta_{s}\sim q(\theta) (8)
=:\displaystyle=: awn,\displaystyle\mathcal{L}_{\text{awn}},

where the outer sum is over the training samples. The “trick” that Hinton & Van Camp (1993) introduce is that the prior p(θ)p(\theta) is not set or further specified by a hyper-prior but instead learned as any other parameter in the model and thus essentially set by data. The contribution of Graves (2011) was then to approximate the expectation in Equation 7 by Monte Carlo sampling with Equation 8.

Here we use the previously introduced techniques to find a closed-form approximation to adaptive weight noise. Consider a single layer with θ={𝐰}\theta=\{\mathbf{w}\}, y=f(𝐱T𝐰)y=f(\mathbf{x}^{T}\mathbf{w}), where we have no dropout variables and the weights are Gaussian distributed with 𝐰𝒩(μ𝐰,σ𝐰2)\mathbf{w}\sim\mathcal{N}(\mu_{\mathbf{w}},\sigma^{2}_{\mathbf{w}}), with covariance diagonal and organised into a vector. Again, we assume a Gaussian density for a=𝐱T𝐰a=\mathbf{x}^{T}\mathbf{w}. Using the rules from Section 2, we find that

E[a]\displaystyle\text{E}\left[a\right] =E[𝐱]Tμ𝐰,\displaystyle=\text{E}\left[\mathbf{x}\right]^{T}\mu_{\mathbf{w}}, (9)
V[a]\displaystyle\text{V}[a] =V[𝐱]Tμ𝐰2+V[𝐱]Tσ𝐰2+(E[𝐱]2)Tσ𝐰2.\displaystyle=\text{V}[\mathbf{x}]^{T}\mu_{\mathbf{w}}^{2}+\text{V}[\mathbf{x}]^{T}\sigma_{\mathbf{w}}^{2}+(\text{E}\left[\mathbf{x}\right]^{2})^{T}\sigma_{\mathbf{w}}^{2}. (10)

A perspective that we have not taken on so far is that this is a convolution of point predictions, each performed by a slightly different neural network with weights drawn from their respective distributions. Consider a neural network f(𝐱,θ)f(\mathbf{x},\theta) with θ={θi}\theta=\{\theta_{i}\}, where each θi\theta_{i} is a Gaussian distributed random variable with mean μi\mu_{i} and variance σi2\sigma^{2}_{i}. Let the network represent a distribution p(𝐳|θ)p(\mathbf{z}|\theta) for the random variable 𝐲\mathbf{y}, which is the network’s output. The output of the network with marginalised weights will be approximated as such:

θp(𝐳|𝐱,θ)q(θ)𝑑θ𝒩(E[𝐲],V[𝐲]),\displaystyle\int_{\theta}p(\mathbf{z}|\mathbf{x},\theta)q(\theta)d\theta\approx\mathcal{N}(\text{E}\left[\mathbf{y}\right],\text{V}[\mathbf{y}]), (11)

where q(θ)q(\theta) depicts the joint over all weights and the moments of the Gaussian variable on the RHS are obtained as in Equations 9 and 10.

3.1 Output covariance

While above we assumed all covariance matrices to be diagonal, we can easily and efficiently extend the last layer to explicitly model covariance in the output.

Let 𝐱\mathbf{x} be an input to the last layer and 𝐖\mathbf{W} the weight matrix that maps this input to the output. Let 𝐰,o\mathbf{w}_{*,o} and 𝐰,p\mathbf{w}_{*,p} be two distinct columns of the weight matrix 𝐖\mathbf{W} and o=𝐱T𝐰,oo=\mathbf{x}^{T}\mathbf{w}_{*,o} and p=𝐱T𝐰,pp=\mathbf{x}^{T}\mathbf{w}_{*,p} their respective outputs given 𝐱\mathbf{x}. In this model, we assume that oo and pp are not independent and need to extend the equation of variance propagation for addition

V[A+B]=V[A]+V[B]+2cov[A,B]\displaystyle\text{V}[A+B]=\text{V}[A]+\text{V}[B]+2\,\text{cov}[A,B] (12)

for dependent outputs.

Plugging oo and pp into eq. 12, rearranging and using eq. 6, we can derive a simple formula for the covariance. (Note that since this assumes independence of 𝐰,o\mathbf{w}_{*,o} and 𝐰,p\mathbf{w}_{*,p}, it does not hold for the diagonal entries of the covariance matrix.)

2cov[o,p]=\displaystyle 2\text{cov}[o,p]= V[o+p]V[o]V[p]\displaystyle\text{V}[o+p]-\text{V}[o]-\text{V}[p]
=\displaystyle= V[𝐱T𝐰,o+𝐛o+𝐱T𝐰,p+𝐛p]V[𝐱T𝐰,o+𝐛o]V[𝐱T𝐰,p+𝐛p]\displaystyle\text{V}[\mathbf{x}^{T}\mathbf{w}_{*,o}+\mathbf{b}_{o}+\mathbf{x}^{T}\mathbf{w}_{*,p}+\mathbf{b}_{p}]-\text{V}[\mathbf{x}^{T}\mathbf{w}_{*,o}+\mathbf{b}_{o}]-\text{V}[\mathbf{x}^{T}\mathbf{w}_{*,p}+\mathbf{b}_{p}]
=\displaystyle= V[𝐱T(𝐰,o+𝐰,p)]+V[𝐛o]+V[𝐛p]\displaystyle\text{V}[\mathbf{x}^{T}(\mathbf{w}_{*,o}+\mathbf{w}_{*,p})]+\text{V}[\mathbf{b}_{o}]+\text{V}[\mathbf{b}_{p}]
(V[𝐱T𝐰,o]+V[𝐛o])(V[𝐱T𝐰,p]+V[𝐛p])\displaystyle-(\text{V}[\mathbf{x}^{T}\mathbf{w}_{*,o}]+\text{V}[\mathbf{b}_{o}])-(\text{V}[\mathbf{x}^{T}\mathbf{w}_{*,p}]+\text{V}[\mathbf{b}_{p}])
=\displaystyle= V[𝐱T(𝐰,o+𝐰,p)]V[𝐱T𝐰,o]V[𝐱T𝐰,p].\displaystyle\text{V}[\mathbf{x}^{T}(\mathbf{w}_{*,o}+{\mathbf{w}_{*,p}})]-\text{V}[\mathbf{x}^{T}\mathbf{w}_{*,o}]-\text{V}[\mathbf{x}^{T}{\mathbf{w}_{*,p}}]. (13)

By applying rules for variance propagation from Section 2.1 and rearranging we arrive at:

cov[o,p]=\displaystyle\text{cov}[o,p]= V[𝐱]T(μ𝐰,oμ𝐰,p),\displaystyle\text{V}[\mathbf{x}]^{T}(\mu_{\mathbf{w}_{*,o}}\circ\mu_{\mathbf{w}_{*,p}}),

where \circ denotes the Hadamard product.

We can show that the diagonal entries of the covariance matrix are computed in the same way as the variances of diagonal-covariance FAWN (FAWN). For the “additional” terms on the diagonal, we define

𝐕=diag(σ𝐛2+σ𝐰,o2TE[𝐱]2+V[𝐱]Tσ𝐰,o2)\displaystyle\mathbf{V}=\operatorname{diag}(\sigma_{\mathbf{b}}^{2}+{\sigma_{\mathbf{w}_{*,o}}^{2}}^{T}\text{E}\left[\mathbf{x}\right]^{2}+\text{V}[\mathbf{x}]^{T}\sigma_{\mathbf{w}_{*,o}}^{2})

and can then write the covariance matrix for full-covariance FAWN (Co-FAWN) in matrix notation:

𝐂=𝐕+i𝐂i=𝐕+iV[xi]μ𝐰i,μ𝐰i,T,\displaystyle\mathbf{C}=\mathbf{V}+\sum_{i}\mathbf{C}_{i}=\mathbf{V}+\sum_{i}\text{V}[x_{i}]\mu_{\mathbf{w}_{i,*}}\mu_{\mathbf{w}_{i,*}}^{T},

where 𝐰i,\mathbf{w}_{i,*} is the ii-th row of 𝐖\mathbf{W}.

3.1.1 Computational efficiency

For matrices, which are updated by adding the outer product of two vectors, the Sherman-Morrison formula,

(𝐀+𝐮𝐯T)1=𝐀1𝐀1𝐮𝐯T𝐀11+𝐯T𝐀1𝐮,\displaystyle(\mathbf{A}+\mathbf{u}\mathbf{v}^{T})^{-1}=\mathbf{A}^{-1}-\frac{\mathbf{A}^{-1}\mathbf{u}\mathbf{v}^{T}\mathbf{A}^{-1}}{1+\mathbf{v}^{T}\mathbf{A}^{-1}\mathbf{u}}, (14)

presents a means of updating the inverse with an outer vector product. Similarly, the determinant of such a matrix can be updated using the matrix inversion lemma:

det(𝐀+𝐮𝐯T)=(1+𝐯T𝐀1𝐮)det(𝐀)\displaystyle\det(\mathbf{A}+\mathbf{u}\mathbf{v}^{T})=(1+\mathbf{v}^{T}\mathbf{A}^{-1}\mathbf{u})\det(\mathbf{A}) (15)

We define

𝐀i+1=𝐀i+𝐮i𝐯iT\displaystyle\mathbf{A}_{i+1}=\mathbf{A}_{i}+\mathbf{u}_{i}\mathbf{v}_{i}^{T}

and can now recursively compute the determinant and inverse of 𝐂\mathbf{C}, which are needed to compute the loss, by setting 𝐀0=𝐕\mathbf{A}_{0}=\mathbf{V}, for which inversion and determinant computations are cheap, 𝐮i=V[xi]E[𝐰i,]\mathbf{u}_{i}=\text{V}[x_{i}]\text{E}\left[\mathbf{w}_{i,*}\right] and 𝐯i=E[𝐰i,]\mathbf{v}_{i}=\text{E}\left[\mathbf{w}_{i,*}\right] and repeatedly using eqs. 14 and 15 until we get the precision matrix 𝐀n1=𝐂1\mathbf{A}_{n}^{-1}=\mathbf{C}^{-1} and its determinant respectively.

The depth of the recursion corresponds to the number of hidden units in the last hidden layer nn.

3.2 Binary Weights

In cases where memory and computational resources are limited, one can use Bernoulli distributed weights instead of Normal distributions. This will half the amount of parameters needed. When using Bernoulli-distributed weights the same variance propagation rules as for Gaussian distributed weights apply. The only difference is in the mean and variance of the weight noise process:

E[𝐰]\displaystyle\text{E}\left[\mathbf{w}\right] =(p0.5)s,\displaystyle=(p-0.5)s, (16)
V[𝐰]\displaystyle\text{V}[\mathbf{w}] =p(1p)s2.\displaystyle=p(1-p)s^{2}. (17)

with ss as an additional weight scaler parameter and pp as the parameter defining a Bernoulli distribution. This parameter ss helps the network to learn a richer set of functions since it would otherwise be limited to values between zero and one. We compared the results against regular FAWN as shown in Table 1 as FAWN-BERN.

3.2.1 Justification by Sampling

We compared the empirical distribution of outputs from the binary weights network with the variance propagation estimation. Sampling from the output of a Bernoulli-distributed weights network is done by sampling weight matrices from the distribution of the weights wB(1,p)w^{\prime}\sim B(1,p) and scaling them with the parameters ss through w=(w0.5)sw=(w^{\prime}-0.5)s. These sampled weight matrices are then used in a standard neural network to produce a sample from p(𝐳|𝐱,θ)p(\mathbf{z}|\mathbf{x},\theta). Histograms of these sampled outputs showed no significant deviation from the variance propagation approximation.

3.3 Fast Variational Inference for Gaussian Likelihoods

We will now use variance propagation to obtain an approximation to the first term of vi\mathcal{L}_{\text{vi}} for the special case of a Gaussian likelihood.

Consider the first term of the RHS of Equation 7 for the case that 𝐳\mathbf{z} is assumed to be a univariate Gaussian. We will thus write zz for the targets and yy for the output of the network and leave out the dependency on θ\theta for brevity. Then,

E[logp(z|y)]\displaystyle\text{E}\left[\log p(z|y)\right]
=\displaystyle= E[log𝒩(z|y,σ2)]\displaystyle\text{E}\left[\log\mathcal{N}(z|y,\sigma^{2})\right]
=\displaystyle= E[(zy)22σ2log2πσ]\displaystyle\text{E}\left[{-(z-y)^{2}\over 2\sigma^{2}}-\log\sqrt{2\pi}\sigma\right]
=\displaystyle= E[(zy)2]2σ2log2πσ\displaystyle{-\text{E}\left[(z-y)^{2}\right]\over 2\sigma^{2}}-\log\sqrt{2\pi}\sigma
=\displaystyle= V[y]2σ2(zE[y])22σ2log2πσ\displaystyle-{\text{V}[y]\over 2\sigma^{2}}-{(z-\text{E}\left[y\right])^{2}\over 2\sigma^{2}}-\log\sqrt{2\pi}\sigma
=\displaystyle= log𝒩(V[y]|0,σ2)+log𝒩(z|E[y],σ2)\displaystyle\log\mathcal{N}(\sqrt{\text{V}[y]}|0,\sigma^{2})+\log\mathcal{N}(z|\text{E}\left[y\right],\sigma^{2})
+log2πσ.\displaystyle+\log\sqrt{2\pi}\sigma.

where we have made use of the identity V[y]=E[y2]E[y]2\text{V}[y]=\text{E}\left[y^{2}\right]-\text{E}\left[y\right]^{2}. The last line offers a partially probabilistic interpretation of this specific instance of variational inference. It puts a zero-centred prior on the square root of the output’s variance and on the error, sharing the same (prior) variance—which is itself encouraged to be large. The last term can be seen as a measure against the variance collapsing to zero, which would lead to large likelihoods on the training set. We refer to this method as FAWN-VI.

3.4 Optimisation of the predictive distribution with regularisation

Since we now have an efficient approximation of the predictive distribution (cf. Equation 3 and Equation 1), an obvious next step is to directly optimise it with respect to the parameter distributions q(θ)q(\theta). This will essentially lead to a maximum likelihood approach and thus inherit its tendency to overfit the training data. Accounting for that is possible by a fully Bayesian treatment, which means to impose a hyperprior on q(θ)q(\theta) and integrate it out.

Here we shall follow a different route, which is to make use of a regulariser, namely the KL-divergence between q(θ)q(\theta) and a prior p(θ)p(\theta):

fawn:=ilogθq(θ)p(𝐳i|𝐱i,θ)dθ+𝕂𝕃[q(θ)||p(θ)],\displaystyle\mathcal{L}_{\text{fawn}}:=-\sum_{i}\log\int_{\theta}q(\theta)p({}^{i}\mathbf{z}|{}^{i}\mathbf{x},\theta)d\theta+\mathbb{KL}[q(\theta)||p(\theta)],

where the sum runs over the training samples 𝒟train={(𝐱i,𝐳i)}i=1N\mathcal{D}_{\text{train}}=\{({}^{i}\mathbf{x},{}^{i}\mathbf{z})\}_{i=1}^{N}. We refer to this method as FAWN-ROPD.

4 Experiments

We evalutated FAWN-VI and FAWN-ROPD from Sections 3.3 and 3.4 respectively on a range of static regression tasks using FFN. We are interested in finding not only a point prediction but a whole predictive distribution. These tasks are typically not where neural networks excel and practicioners resort to GP instead, which is why we compare to those.

To this end we used a global univariate Gaussian for the prior and a Gaussian as a variational approximation for each of the parameters:

p(θ)=\displaystyle p(\theta)= i𝒩(θi|μ~,σ~2),\displaystyle\prod_{i}\mathcal{N}(\theta_{i}|\tilde{\mu},\tilde{\sigma}^{2}),
q(θ)=\displaystyle q(\theta)= i𝒩(θi|μ˙i,σ˙i2).\displaystyle\prod_{i}\mathcal{N}(\theta_{i}|\dot{\mu}_{i},\dot{\sigma}_{i}^{2}).

The KL-divergence is then given by11 1 Obtained with the help of the Q&A community “crossvalidated” at http://stats.stackexchange.com/questions/7440/kl-divergence-between-two-univariate-gaussians.:

𝕂𝕃[q(θ)||p(θ)]=ilogσ~σ˙i+σ˙i2+(μ˙iμ~)22σ~212.\displaystyle\mathbb{KL}[q(\theta)||p(\theta)]=\sum_{i}\log\frac{\tilde{\sigma}}{\dot{\sigma}_{i}}+\frac{\dot{\sigma}_{i}^{2}+(\dot{\mu}_{i}-\tilde{\mu})^{2}}{2\tilde{\sigma}^{2}}-\frac{1}{2}.

Additionally, we chose a Gaussian likelihood where we assumed that

zi=yi+ϵi,ϵi𝒩(0,σ^i2),\displaystyle z_{i}=y_{i}+\epsilon_{i},\epsilon_{i}\sim\mathcal{N}(0,\hat{\sigma}_{i}^{2}),

which resembles a Gaussian distributed measurement error with variance σ^i\hat{\sigma}_{i} for output dimension ii. We integrate the σ^i\hat{\sigma}_{i} into the set of parameters and optimise it jointly with all other parameters.

All experiments were performed using a similar protocol to the one used in Hernández-Lobato & Adams (2015): we used single-layer networks with 50 hidden units using the rectifier transfer function. We report the negative log likelihood of the data with means and standard deviations coming from ten different random splits into 90% training and 10% testing data. The parameters of neural networks using FAWN were drawn from a zero-centred Gaussian with standard deviation 0.2.

Training was performed using Adam (Kingma & Ba, 2014) with a step rate of α=0.001\alpha=0.001 until convergence of the training loss. No separate validation set was used. Gradients were estimated using 128 samples in a single mini batch.

The results for GP were obtained using a the sum of a linear and a squared exponential kernel using automatic relevance determination. Three random restarts were performed. We used GPy (GPy authors, 2012–2014) for the experiments.

The results are summarised in Table 1. The proposed methods place themselves well among alternative approaches, where FAWN-ROPD is better than FAWN-VI in all cases.

Table 1: Results for FAWN. Results for probabilistic backpropagation (PBP) and adaptive weight noise (VI) taken from Hernández-Lobato & Adams (2015). Results for GP obtained via GPy (GPy authors, 2012–2014), where no results for the slightly bigger data sets (more than 1500 samples) were obtained due to the increased run time. Best results shown in bold.
VI PBP GP FAWN-VI FAWN-ROPD FAWN-BERN
Boston 2.903±\pm0.071 2.550±\pm0.089 2.631±\pm0.289 3.005±\pm0.273 2.559±\pm0.161 2.685±\pm0.196
Concrete 3.391±\pm0.017 3.136±\pm0.021 2.893±\pm0.095 3.183±\pm0.077 3.107±\pm0.134 3.310±\pm0.109
Energy 2.391±\pm0.029 1.982±\pm0.027 0.711±\pm1.477 1.762±\pm0.655 1.369±\pm0.842 2.095±\pm0.077
Kin8Nm 0.897±\pm0.010 -0.964±\pm0.007 -1.006±\pm0.027 -1.211±\pm0.032 -0.601±\pm0.021
Naval -3.734±\pm0.116 -3.653±\pm0.004 -6.751±\pm0.118 -6.837±\pm0.131 -3.608±\pm0.066
Power Plant 2.890±\pm0.010 2.838±\pm0.008 2.849±\pm0.042 2.819±\pm0.029 2.859±\pm0.031
Protein 2.992±\pm0.006 2.974±\pm0.002 2.973±\pm0.022 2.882±\pm0.068 3.005±\pm0.013
Wine 0.980±\pm0.013 0.966±\pm0.014 0.943±\pm0.037 0.908±\pm0.078 0.934±\pm0.085
Yacht 3.439±\pm0.163 1.483±\pm0.018 0.615±\pm0.756 1.448±\pm0.393 0.336±\pm0.271 3.201±\pm0.191
Year 3.622±\pm N/A 3.603±\pm N/A 3.807±\pm N/A 3.472±\pm N/A    –
Table 2: Results for FAWN and Co-FAWN used on multi-output datasets. For the Jura dataset we train on the location coordinates only and predict the local concentrations of the six different elements. Best results shown in bold.
N D out FAWN-ROPD Co-FAWN
Energy 768 8 2 2.1218±\pm0.7024 2.1063±\pm0.8357
Naval 11’934 16 2 -14.9868±\pm0.7368 -15.1074±\pm0.3656
Sarcos 48’933 21 7 -4.4185±\pm N/A -5.1867±\pm N/A     
Jura 358 2 7 11.1407±\pm N/A 8.6396±\pm N/A     
Table 3: Size of Datasets
N D
Boston 506 13
Concrete 1030 8
Energy 768 8
Kin8Nm 8192 8
Naval 11’934 16
Power Plant 9568 4
Protein 45’730 9
Wine 1599 11
Yacht 308 6
Year 515’345 90

5 Conclusion and Future Work

We have proposed a method to approximate the marginal likelihood of a distribution over neural network weights up to its mean and variance. This enabled us to derive a deterministic approximation of variational Bayes for Gaussian likelihoods and propose a novel, less subjective flavour of variational inference, FAWN-ROPD. The experimental results show that FAWN-ROPD obtains competitive performance over a wide range of regression tasks. These tasks include ones with very little samples (order of a few hundred) as well as many samples (several thousands) and range from domains such as robotics, predictive maintenance, computational biology and others.

The method requires further evaluation: we will experimentally investigate more common deep-learning architectures such as recurrent neural networks and deep multilayer perceptrons. Further, the suitability of FAWN for tasks where model uncertainty in the predictions is of interest, such as active learning or reinforcement learning, needs to be tested. On the theoretical side, the exact relationship of FAWN-ROPD to reference priors remains unclear and a theoretically founded motivation for FAWN-ROPD is an important next step.

FAWN
Fast Adaptive Weight Noise
VB
Variational Bayes
MDL
Minimum Description Length
VI
Variational Inference
FFN
Feed-Forward Neural Network
GP
Gaussian Processes

References

  • Bergstra et al. (2010) Bergstra, James, Breuleux, Olivier, Bastien, Frédéric, Lamblin, Pascal, Pascanu, Razvan, Desjardins, Guillaume, Turian, Joseph, Warde-Farley, David, and Bengio, Yoshua. Theano: a CPU and GPU math expression compiler. In Proceedings of the Python for Scientific Computing Conference (SciPy), June 2010. URL http://www.iro.umontreal.ca/~lisa/pointeurs/theano_scipy2010.pdf. Oral Presentation.
  • Blundell et al. (2015) Blundell, Charles, Cornebise, Julien, Kavukcuoglu, Koray, and Wierstra, Daan. Weight uncertainty in neural networks. arXiv:1505.05424 [cs, stat], 2015.
  • Buntine & Weigend (1991) Buntine, Wray L and Weigend, Andreas S. Bayesian back-propagation. Complex systems, 5(6):603–643, 1991.
  • GPy authors (2012–2014) GPy authors, The. GPy: A Gaussian process framework in python. http://github.com/SheffieldML/GPy, 2012–2014.
  • Graves (2011) Graves, Alex. Practical variational inference for neural networks. In Advances in Neural Information Processing Systems, pp. 2348–2356, 2011.
  • Graves (2013) Graves, Alex. Generating sequences with recurrent neural networks. arXiv preprint arXiv:1308.0850, 2013.
  • Grimmett & Stirzaker (1992) Grimmett, Geoffrey and Stirzaker, David. Probability and random processes, volume 2. Oxford Univ Press, 1992.
  • Grünwald (2007) Grünwald, Peter D. The minimum description length principle. MIT press, 2007.
  • Hernández-Lobato & Adams (2015) Hernández-Lobato, José Miguel and Adams, Ryan P. Probabilistic backpropagation for scalable learning of bayesian neural networks. arXiv preprint arXiv:1502.05336, 2015.
  • Hinton & Van Camp (1993) Hinton, Geoffrey E and Van Camp, Drew. Keeping the neural networks simple by minimizing the description length of the weights. In Proceedings of the sixth annual conference on Computational learning theory, pp. 5–13. ACM, 1993.
  • Hinton et al. (2012) Hinton, Geoffrey E, Srivastava, Nitish, Krizhevsky, Alex, Sutskever, Ilya, and Salakhutdinov, Ruslan R. Improving neural networks by preventing co-adaptation of feature detectors. arXiv preprint arXiv:1207.0580, 2012.
  • Julier & Uhlmann (1997) Julier, Simon J and Uhlmann, Jeffrey K. New extension of the kalman filter to nonlinear systems. In AeroSense’97, pp. 182–193. International Society for Optics and Photonics, 1997.
  • Kingma & Ba (2014) Kingma, Diederik and Ba, Jimmy. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
  • Kingma & Welling (2013) Kingma, Diederik P and Welling, Max. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
  • Kingma et al. (2015) Kingma, Diederik P, Salimans, Tim, and Welling, Max. Variational dropout and the local reparameterization trick. arXiv preprint arXiv:1506.02557, 2015.
  • MacKay (1992) MacKay, David JC. A practical bayesian framework for backpropagation networks. Neural computation, 4(3):448–472, 1992.
  • MacKay (1995) MacKay, David JC. Probable networks and plausible predictions-a review of practical bayesian methods for supervised neural networks. Network: Computation in Neural Systems, 6(3):469–505, 1995.
  • Neal (1993) Neal, Radford M. Probabilistic inference using markov chain monte carlo methods. Technical report, Department of Computer Science, University of Toronto Toronto, CA, 1993.
  • Rissanen (1985) Rissanen, Jorma. Minimum-description-length principle. Encyclopedia of statistical sciences, 1985.
  • Wan et al. (2013) Wan, Li, Zeiler, Matthew, Zhang, Sixin, Cun, Yann L, and Fergus, Rob. Regularization of neural networks using dropconnect. In Proceedings of the 30th International Conference on Machine Learning (ICML-13), pp. 1058–1066, 2013.
  • Wang & Manning (2013) Wang, Sida and Manning, Christopher. Fast dropout training. In Proceedings of the 30th International Conference on Machine Learning (ICML-13), pp. 118–126, 2013.