57
Bayesian Convolutional Neural Networks with Bernoulli Approximate Variational Inference Yarin Gal [email protected]

Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian Convolutional Neural Networks withBernoulli Approximate Variational Inference

Yarin Gal

[email protected]

Page 2: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian Convnets

In this talk we’ll —

I Offer insights into why recent state-of-the-art models in imageprocessing work so well.

I Start with an approximation of a BNP model and through a(beautiful) derivation...

I ... obtain insights into getting state-of-the-art results onCIFAR-10 dataset (7.71% test error).

2 of 34

Page 3: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

GP regression

Gaussian processes (GPs) are a powerful tool for probabilisticinference over functions.

I GP regression captures non-linear functions

GPs offer:I uncertainty estimates,

I robustness to over-fitting,

I and principled ways for tuning hyper-parameters

3 of 34

Page 4: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

GP regressionI Training dataset with N inputs X ∈ RN×Q (Q dimensional)

I Corresponding D dimensional outputs Fn = f(Xn)

I We place a Gaussian process prior over the space of functions

f ∼ GP(mean µ(x), covariance k(x,x′))

Every finite subset of variables follows a joint Gaussiandistribution

I This implies a joint Gaussian distribution over function values:

p(F |X ) = N (F ;µ(X ),K ), Kij = k(xi ,xj)

I Y consists of noisy observations, making the functions F latent:

p(Y |F ) = N (Y ; F , τ−1In)

I Prior and likelihood conjugate:

p(Y |X ) = N (Y ; 0,K + τ−1In)

4 of 34

Page 5: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

GP regressionI Training dataset with N inputs X ∈ RN×Q (Q dimensional)

I Corresponding D dimensional outputs Fn = f(Xn)

I We place a Gaussian process prior over the space of functions

f ∼ GP(mean µ(x), covariance k(x,x′))

Every finite subset of variables follows a joint Gaussiandistribution

I This implies a joint Gaussian distribution over function values:

p(F |X ) = N (F ;µ(X ),K ), Kij = k(xi ,xj)

I Y consists of noisy observations, making the functions F latent:

p(Y |F ) = N (Y ; F , τ−1In)

I Prior and likelihood conjugate:

p(Y |X ) = N (Y ; 0,K + τ−1In)

4 of 34

Page 6: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

GP regressionI Training dataset with N inputs X ∈ RN×Q (Q dimensional)

I Corresponding D dimensional outputs Fn = f(Xn)

I We place a Gaussian process prior over the space of functions

f ∼ GP(mean µ(x), covariance k(x,x′))

Every finite subset of variables follows a joint Gaussiandistribution

I This implies a joint Gaussian distribution over function values:

p(F |X ) = N (F ;µ(X ),K ), Kij = k(xi ,xj)

I Y consists of noisy observations, making the functions F latent:

p(Y |F ) = N (Y ; F , τ−1In)

I Prior and likelihood conjugate:

p(Y |X ) = N (Y ; 0,K + τ−1In)

4 of 34

Page 7: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

GP regressionI Training dataset with N inputs X ∈ RN×Q (Q dimensional)

I Corresponding D dimensional outputs Fn = f(Xn)

I We place a Gaussian process prior over the space of functions

f ∼ GP(mean µ(x), covariance k(x,x′))

Every finite subset of variables follows a joint Gaussiandistribution

I This implies a joint Gaussian distribution over function values:

p(F |X ) = N (F ;µ(X ),K ), Kij = k(xi ,xj)

I Y consists of noisy observations, making the functions F latent:

p(Y |F ) = N (Y ; F , τ−1In)

I Prior and likelihood conjugate:

p(Y |X ) = N (Y ; 0,K + τ−1In)

4 of 34

Page 8: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

GP regressionI Training dataset with N inputs X ∈ RN×Q (Q dimensional)

I Corresponding D dimensional outputs Fn = f(Xn)

I We place a Gaussian process prior over the space of functions

f ∼ GP(mean µ(x), covariance k(x,x′))

Every finite subset of variables follows a joint Gaussiandistribution

I This implies a joint Gaussian distribution over function values:

p(F |X ) = N (F ;µ(X ),K ), Kij = k(xi ,xj)

I Y consists of noisy observations, making the functions F latent:

p(Y |F ) = N (Y ; F , τ−1In)

I Prior and likelihood conjugate:

p(Y |X ) = N (Y ; 0,K + τ−1In)

4 of 34

Page 9: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

GP regressionI Training dataset with N inputs X ∈ RN×Q (Q dimensional)

I Corresponding D dimensional outputs Fn = f(Xn)

I We place a Gaussian process prior over the space of functions

f ∼ GP(mean µ(x), covariance k(x,x′))

Every finite subset of variables follows a joint Gaussiandistribution

I This implies a joint Gaussian distribution over function values:

p(F |X ) = N (F ;µ(X ),K ), Kij = k(xi ,xj)

I Y consists of noisy observations, making the functions F latent:

p(Y |F ) = N (Y ; F , τ−1In)

I Prior and likelihood conjugate:

p(Y |X ) = N (Y ; 0,K + τ−1In)

4 of 34

Page 10: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

However...

Problem – time and space complexity

I Evaluating p(Y |X ) directly is an expensive operation

I Involves the inversion of the N by N matrix K

I requiring O(N3) time complexity

5 of 34

Page 11: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Many Approximations

Full GP:

1650 1700 1750 1800 1850 1900 1950210123

I Sparse pseudo-input cannot handle complex functions well:

1650 1700 1750 1800 1850 1900 1950210123

I Sparse spectrum is known to over-fit:

1650 1700 1750 1800 1850 1900 1950210123

6 of 34

Page 12: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Main Idea:

I Variational Sparse Spectrum GP (VSSGP)I use variational inference for the sparse spectrum approximation

I avoids over-fitting, efficiently captures globally complexbehaviour

I In short—I we replace the GP covariance function with a finite Monte Carlo

approximation

I we view this as a random covariance function

I conditioned on data this random variable has an intractableposterior

I we approximate this posterior with variational inference

7 of 34

Page 13: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Main Idea:

I Variational Sparse Spectrum GP (VSSGP)I use variational inference for the sparse spectrum approximation

I avoids over-fitting, efficiently captures globally complexbehaviour

I In short—I we replace the GP covariance function with a finite Monte Carlo

approximation

I we view this as a random covariance function

I conditioned on data this random variable has an intractableposterior

I we approximate this posterior with variational inference

7 of 34

Page 14: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Main Idea:

I Variational Sparse Spectrum GP (VSSGP)I use variational inference for the sparse spectrum approximation

I avoids over-fitting, efficiently captures globally complexbehaviour

I In short—I we replace the GP covariance function with a finite Monte Carlo

approximation

I we view this as a random covariance function

I conditioned on data this random variable has an intractableposterior

I we approximate this posterior with variational inference

7 of 34

Page 15: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Main Idea:

I Variational Sparse Spectrum GP (VSSGP)I use variational inference for the sparse spectrum approximation

I avoids over-fitting, efficiently captures globally complexbehaviour

I In short—I we replace the GP covariance function with a finite Monte Carlo

approximation

I we view this as a random covariance function

I conditioned on data this random variable has an intractableposterior

I we approximate this posterior with variational inference

7 of 34

Page 16: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Main Idea:

I Variational Sparse Spectrum GP (VSSGP)I use variational inference for the sparse spectrum approximation

I avoids over-fitting, efficiently captures globally complexbehaviour

I In short—I we replace the GP covariance function with a finite Monte Carlo

approximation

I we view this as a random covariance function

I conditioned on data this random variable has an intractableposterior

I we approximate this posterior with variational inference

7 of 34

Page 17: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

2-Slide Review of Variational Inference

I Condition model on a finite set of random variables ω.

I Predictive distribution

p(y∗|x∗,X,Y) =

∫p(y∗|x∗,ω)p(ω|X,Y) dω.

I Can’t evaluate p(ω|X,Y) analytically —

I define an “easier” approximating variational distribution qθ(ω)parametrised by variational parameters θ.

8 of 34

Page 18: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

2-Slide Review of Variational Inference

I Minimise the Kullback–Leibler (KL) divergence:

argminθKL(qθ(ω) | p(ω|X,Y)).

I Minimising KL = maximising log evidence lower bound withrespect to θ:

LVI :=

∫qθ(ω) log p(Y|X,ω)dω − KL(qθ(ω)||p(ω)).

I Gives approximate predictive distribution:

qθ(y∗|x∗) =

∫p(y∗|x∗,ω)qθ(ω)dω.

9 of 34

Page 19: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

How do we apply this to our GP situation? (with a squaredexponential covariance function)

Given Fourier transform of the covariance function:

K(x− y) = σ2e−(x−y)T (x−y)

2

= σ2∫N (w; 0, IQ) cos

(2πwT (x− y)

)dw.

Page 20: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Fourier transform of the squared exponential covariance function:

K(x− y) = σ2∫N (w; 0, IQ) cos

(2πwT (x− y)

)dw,

Auxiliary variable b:

K(x− y) = 2σ2∫N (w; 0, IQ)Unif[0,2π]

cos(2πwT x + b

)cos

(2πwT y + b

)dwdb.

Page 21: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Auxiliary variable b:

K(x− y) = 2σ2∫N (w; 0, IQ)Unif[0,2π]

cos(2πwT x + b

)cos

(2πwT y + b

)dwdb,

Monte Carlo integration with K terms:

K̂(x− y) =2σ2

K

K∑k=1

cos(2πwT

k x + bk)

cos(2πwT

k y + bk)

with wk ∼ N (0, IQ), bk ∼ Unif[0,2π].

Page 22: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Monte Carlo integration with K terms:

K̂(x− y) =2σ2

K

K∑k=1

cos(2πwT

k x + bk)

cos(2πwT

k y + bk),

Rewrite the covariance function with Φ ∈ RN×K

wk ∼ N (0, IQ), bk ∼ Unif[0,2π], ω = {wk ,bk}Kk=1

Φn,k (ω) =

√2σ2

Kcos

(2πwT

k xn + bk),

K̂(x− y) = Φ(ω)Φ(ω)T .

Page 23: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Rewrite the covariance function with Φ ∈ RN×K

wk ∼ N (0, IQ), bk ∼ Unif[0,2π], ω = {wk ,bk}Kk=1

Φn,k (ω) =

√2σ2

Kcos

(2πwT

k xn + bk),

K̂(x− y) = Φ(ω)Φ(ω)T ,

Integrate the GP over the random covariance function

wk ∼ N (0, IQ), bk ∼ Unif[0,2π], ω = {wk ,bk}Kk=1

p(Y|X,ω) = N(Y; 0,Φ(ω)Φ(ω)T + τ−1IN

)p(Y|X) =

∫p(Y|X,ω) p(ω)dω

p(y∗|x∗,X,Y) =

∫p(y∗|x∗,ω)p(ω|X,Y)dω.

Page 24: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Integrate the GP over the random covariance function

wk ∼ N (0, IQ), bk ∼ Unif[0,2π], ω = {wk ,bk}Kk=1

p(Y|X,ω) = N(Y; 0,Φ(ω)Φ(ω)T + τ−1IN

)p(Y|X) =

∫p(Y|X,ω)p(ω)dω

p(y∗|x∗,X,Y) =

∫p(y∗|x∗,ω)p(ω|X,Y)dω.

Use variational distribution q(ω) =∏

q(wk )q(bk ) toapproximate posterior p(ω|X,Y):

q(wk ) = N (µk ,ΣK ), q(bk ) = Unif(αk , βk ),

with ΣK diagonal.

Page 25: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Maximise log evidence lower bound

LVSSGP =12

D∑d=1

(log(|τ−1 Σ |) + τyT

d Eq(ω)(Φ) Σ Eq(ω)(ΦT ) yd + ...

)− KL(q(ω)||p(ω))

with Σ = ( Eq(ω)(ΦT Φ) + τ−1I)−1. We can evaluate the KL andthe expectations analytically using the identity

Eq(w)

(cos(wT x + b)

)= e−

12 xT Σx cos(µT x + b).

Requires O(NK 2 + K 3) time complexity.

Page 26: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Factorised VSSGP

Factorised VSSGP (fVSSGP)I We often use large K .

I K by K matrix inversion is still slow: O(K 3).

I It is silly to invert the whole matrix every time— slightly changing the parameters we expect the inverse tonot change too much.

I We can do better with an additional auxiliary variable.

17 of 34

Page 27: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

We integrated the GP over the random covariance function

wk ∼ N (0, IQ), bk ∼ Unif[0,2π], ω = {wk ,bk}Kk=1

p(Y|X,ω) = N(Y; 0,Φ(ω)Φ(ω)T + τ−1IN

)p(Y|X) =

∫p(Y|X,ω)p(ω)dω,

Introduce auxiliary random variables A ∈ RK×D

A ∼ N (0, IK×D),

p(Y|X,A,ω) = N(Y; Φ(ω)A, τ−1IN

)p(Y|X) =

∫p(Y|X,A,ω)p(A)p(ω)dωdA.

Page 28: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Introduce auxiliary random variables A ∈ RK×D

A ∼ N (0, IK×D),

p(Y|X,A,ω) = N(Y; Φ(ω)A, τ−1IN

)p(Y|X) =

∫p(Y|X,A,ω)p(A)p(ω)dωdA,

Use variational distribution q(ω) =∏

q(wk )q(bk )∏

q(ad ) toapproximate posterior p(ω,A|X,Y):

q(ad ) = N (md ,sd )

over the rows of A with sd diagonal.

Page 29: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Maximise log evidence lower bound

LfVSSGP =D∑

d=1

(τyT

d Eq(ω)

(Φ)md −

τ

2tr(

Eq(ω)(ΦT Φ)(sd + mdmTd ))

+ ...

)− KL(q(A)||p(A))− KL(q(ω)||p(ω)).

Requires O(NK 2) time complexity — no matrix inversion.

Page 30: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Looks Familiar?Let’s rewrite the last model with different notation:

W1 ∼ N (0, IQ×K ), W2 ∼ N (0, IK×D),

ω = {W1,W2,b}p(y|x,ω) = N

(y; W2 cos

(W1x + b

), τ−1IN

)p(y∗|x∗,X,Y) =

∫p(y∗|x∗,ω)p(ω|X,Y)dω.

21 of 34

Page 31: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Looks Familiar?Let’s rewrite the last model with different notation:

W1 ∼ N (0, IQ×K ), W2 ∼ N (0, IK×D),

ω = {W1,W2,b}p(y|x,ω) = N

(y; W2 cos

(W1x + b

), τ−1IN

)p(y∗|x∗,X,Y) =

∫p(y∗|x∗,ω)p(ω|X,Y)dω.

This is a Bayesian neuralnetwork.

21 of 34

Page 32: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Looks Familiar?

I Started with a GP and using variational inference→ Bayesianneural network

I We (approximately) integrate over the weights of the NN

I But we have weird cosine non-linearities

I Let’s replace the covariance function with

K(x,y) =

∫N (w; 0, IQ)p(b)σ(wT x + b)σ(wT y + b)dwdb

with non-linear function σ(·) (ReLU/TanH) and distribution p(b)

I We get σ(·) non-linearities (ReLU/TanH) in our Bayesian NN

22 of 34

Page 33: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Looks Familiar?

I Started with a GP and using variational inference→ Bayesianneural network

I We (approximately) integrate over the weights of the NN

I But we have weird cosine non-linearities

I Let’s replace the covariance function with

K(x,y) =

∫N (w; 0, IQ)p(b)σ(wT x + b)σ(wT y + b)dwdb

with non-linear function σ(·) (ReLU/TanH) and distribution p(b)

I We get σ(·) non-linearities (ReLU/TanH) in our Bayesian NN

22 of 34

Page 34: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Looks Familiar?

I Started with a GP and using variational inference→ Bayesianneural network

I We (approximately) integrate over the weights of the NN

I But we have weird cosine non-linearities

I Let’s replace the covariance function with

K(x,y) =

∫N (w; 0, IQ)p(b)σ(wT x + b)σ(wT y + b)dwdb

with non-linear function σ(·) (ReLU/TanH) and distribution p(b)

I We get σ(·) non-linearities (ReLU/TanH) in our Bayesian NN

22 of 34

Page 35: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Looks Familiar?

I Started with a GP and using variational inference→ Bayesianneural network

I We (approximately) integrate over the weights of the NN

I But we have weird cosine non-linearities

I Let’s replace the covariance function with

K(x,y) =

∫N (w; 0, IQ)p(b)σ(wT x + b)σ(wT y + b)dwdb

with non-linear function σ(·) (ReLU/TanH) and distribution p(b)

I We get σ(·) non-linearities (ReLU/TanH) in our Bayesian NN

22 of 34

Page 36: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Looks Familiar?

I Started with a GP and using variational inference→ Bayesianneural network

I We (approximately) integrate over the weights of the NN

I But we have weird cosine non-linearities

I Let’s replace the covariance function with

K(x,y) =

∫N (w; 0, IQ)p(b)σ(wT x + b)σ(wT y + b)dwdb

with non-linear function σ(·) (ReLU/TanH) and distribution p(b)

I We get σ(·) non-linearities (ReLU/TanH) in our Bayesian NN

22 of 34

Page 37: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Convolutional NNs

We have Bayesian NNs with arbitrary non-linearitiesapproximating various Gaussian processes.

I Replace the neural network with a convolutional neural network

I Convolution operation = inner-product of transformed input

I Integrate over the filters

I But these are often HUGE

I We have wayy too many parameters in our approximation

23 of 34

Page 38: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Convolutional NNs

We have Bayesian NNs with arbitrary non-linearitiesapproximating various Gaussian processes.

I Replace the neural network with a convolutional neural network

I Convolution operation = inner-product of transformed input

I Integrate over the filters

I But these are often HUGE

I We have wayy too many parameters in our approximation

23 of 34

Page 39: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Convolutional NNs

We have Bayesian NNs with arbitrary non-linearitiesapproximating various Gaussian processes.

I Replace the neural network with a convolutional neural network

I Convolution operation = inner-product of transformed input

I Integrate over the filters

I But these are often HUGE

I We have wayy too many parameters in our approximation

23 of 34

Page 40: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Convolutional NNs

We have Bayesian NNs with arbitrary non-linearitiesapproximating various Gaussian processes.

I Replace the neural network with a convolutional neural network

I Convolution operation = inner-product of transformed input

I Integrate over the filters

I But these are often HUGE

I We have wayy too many parameters in our approximation

23 of 34

Page 41: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Convolutional NNs

We have Bayesian NNs with arbitrary non-linearitiesapproximating various Gaussian processes.

I Replace the neural network with a convolutional neural network

I Convolution operation = inner-product of transformed input

I Integrate over the filters

I But these are often HUGE

I We have wayy too many parameters in our approximation

23 of 34

Page 42: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Computational Efficiency

Too many parameters...

I Gaussian approximating distributions→ Bernoullis

I Random weights defined as Wi = MiBi with variationalparameters Mi and Bi diagonal: Bi,jj ∼ Bern(pi)

I Doesn’t use more parameters than normal NNs

24 of 34

Page 43: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Computational Efficiency

Problem: can’t integrate analytically

I Use MC integration instead with stochastic optimisation

In practiceI Sample Bernoulli realisations and multiply rows of Mi→ identical to setting NN units to zero with probability pi

25 of 34

Page 44: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Computational Efficiency

Problem: can’t integrate analyticallyI Use MC integration instead with stochastic optimisation

In practiceI Sample Bernoulli realisations and multiply rows of Mi→ identical to setting NN units to zero with probability pi

This is dropout(an empirical technique in deep learning to avoid over-fitting)

25 of 34

Page 45: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian convnets

So...

Dropout = Bayesian NN = Bernoulli approximatevariational inference in GP

I Can implement Bayesian convnets with Bernoulli approximatevariational inference with existing tools!

I Dropout implemented in every deep learning package

I Just do dropout after every convolution layer

Someone must have tried it in the past?

26 of 34

Page 46: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian convnets

Dropout after every convolution layer:

I On CIFAR-10 with a small LeNet model

I Implemented only after inner-product layers in existingliterature — 23.46 test error

I We got test error 41.82.

27 of 34

Page 47: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian convnets

Why?

I Dropout implementation uses full weight matrices at test time

But...

28 of 34

Page 48: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian convnets

Why?

I Dropout implementation uses full weight matrices at test time

But...I Dropout is a Bayesian model

I Should estimate mean of posterior (e.g. MC integration):

p(y∗|x∗,X,Y) =

∫p(y∗|x∗,ω)p(ω|X,Y)dω

≈∫

p(y∗|x∗,ω)q(ω)dω

≈ 1T

T∑t=1

p(y∗|x∗,ωt )q(ωt ),(ωt ∼ q(ω)

).

referred to as MC dropout.

28 of 34

Page 49: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian convnets

MC dropout after every convolution layer:

I On CIFAR-10 with a small LeNet model

I Training same as before, at test time average T stochasticsamples from the network

I We get 16.05± 0.07 test error averaging 100 samples!(41.82 before, 23.46 after inner-product alone)

29 of 34

Page 50: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian convnets

How do we compare to standard techniques? (CIFAR-10 LeNet)

103 104 105

Batches

15

20

25

30

35

40

45

50

55

60Err

or

(%)

Standard dropout (lenet-all)

MC dropout (lenet-all)

Standard dropout (lenet-ip)

MC dropout (lenet-ip)

No dropout (lenet-none)

30 of 34

Page 51: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

Bayesian convnets

How do we compare to standard techniques? (MNIST LeNet)

104 105 106 107

Batches

0.4

0.6

0.8

1.0

1.2

1.4

1.6

1.8Err

or

(%)

Standard dropout (lenet-all)

MC dropout (lenet-all)

Standard dropout (lenet-ip)

MC dropout (lenet-ip)

No dropout (lenet-none)

31 of 34

Page 52: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

State of the art

MC dropout in state-of-the-art models (T = 100 averaged with 5repetitions):

Test error Test errorModel (Standard dropout) (MC dropout)

NIN 10.43 10.27± 0.05

DSN 9.37 9.32± 0.02

Augmented-DSN 7.95 7.71± 0.09

Lowest error obtained is 7.51

32 of 34

Page 53: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

What’s next

Many new insights

I Existing techniques in deep learning approximate Bayesiannon-parametrics models

I Dropout integrates over network weights

I Dropout approximation doesn’t work in convnets but integratingover the weights is still good

I

Opens the door for many new ap-plications (model uncertainty, princi-pled extensions, etc.)

33 of 34

Page 54: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

What’s next

Many new insights

I Existing techniques in deep learning approximate Bayesiannon-parametrics models

I Dropout integrates over network weights

I Dropout approximation doesn’t work in convnets but integratingover the weights is still good

I

Opens the door for many new ap-plications (model uncertainty, princi-pled extensions, etc.)

33 of 34

Page 55: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

What’s next

Many new insights

I Existing techniques in deep learning approximate Bayesiannon-parametrics models

I Dropout integrates over network weights

I Dropout approximation doesn’t work in convnets but integratingover the weights is still good

I

Opens the door for many new ap-plications (model uncertainty, princi-pled extensions, etc.)

33 of 34

Page 56: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

What’s next

Many new insights

I Existing techniques in deep learning approximate Bayesiannon-parametrics models

I Dropout integrates over network weights

I Dropout approximation doesn’t work in convnets but integratingover the weights is still good

I

Opens the door for many new ap-plications (model uncertainty, princi-pled extensions, etc.)

33 of 34

Page 57: Bayesian Convolutional Neural Networks with Bernoulli ... · GP regression Gaussian processes (GPs) are a powerful tool for probabilistic inference over functions. I GP regression

What’s next

Finally, have a look at http://goo.gl/q8OlGK

Thank you for listening

34 of 34