tensorflow / tensorflow/probability
Apply prior on a simple linear regression
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hello everyone !
I am both a beginner in bayesian stats and probabilistic programming,
I am trying to do simple linear regression with a toy dataset with a predefined prior on the bias.
So far I have found several ways of doing bayesian linear regressions with TFP (correct me if I'm wrong) including: using a shallow neural network with one Dense flipout layer, GLMs, STS models, Edward2 models.
Let's say my dataset is the linear relationship 3x + 1 + noise, what would be the best method to fit a linear regression saying explicity my prior was distributed on a Normal distribution centered in 10 (to force the bias posterior to be a compromise between 1 and 10).
So far I found that maybe the DenseFlipout option was the best with a simple architecture as such:
model = tf.keras.Sequential([
tfp.layers.DenseFlipout(
1,
activation = "linear",
bias_prior_fn = tfp.layers.default_mean_field_normal_fn()
)
])
model.compile(optimizer = "adam",loss = "mse")
But do I define a custom prior on the bias ? The documentation around the default_mean_field_normal_fn() is obscure.
Also my goal is to be the more generalizable as possible, with custom distributions for the priors, or priors on the coefficients as well.
Thanks a lot !
Theo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides a tf.keras.Sequential example using tfp.layers.DenseFlipout and default_mean_field_normal_fn(), but names no repository file or test. Start by locating the relevant DenseFlipout and prior-function documentation or examples, then determine whether the request needs documentation clarification or an API change and define acceptance criteria for custom bias and coefficient priors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- machine-learning
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100