tensorflow / tensorflow/probability

Is it possible to have a mixture of distributions as the prior of a Bayesian layer?

Open
#816 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

The paper Weight Uncertainty in Neural Networks proposes the usage of a mixture of two Gaussians as the prior distribution. By default, the priors (of the kernel and bias) of a Convolution2DFlipout layer are Gaussians. Is there an easy way of having a mixture of Gaussians as the priors?

I know TFP provides the class MixtureSameFamily. For example, you can create a mixture of two Gaussians in the following way.

from tensorflow_probability import distributions as tfd

prior = tfd.MixtureSameFamily(tfd.Categorical(probs=[0.4, 0.6]),
                              components_distribution=tfd.Normal(
                                  loc=[-1., 1],  # One for each component.
                                  scale=[0.1, 0.5])
                              )

In order to have a mixture of two Gaussians as the prior of a Bayesian layer, there must be a way of computing the KL divergence between a mixture of two Gaussians and another Gaussian (the posterior). After having had looked at the documentation of tfp.distributions.kl_divergence, apparently, this is not yet implemented.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Convolution2DFlipout Bayesian layer and tfp.distributions.kl_divergence, then review how MixtureSameFamily represents the proposed prior. Done means a mixture-of-Gaussians prior can be used with the layer and its KL divergence against the Gaussian posterior is supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.