tensorflow / tensorflow/probability
Tracing only a subset of state variables in mcmc.sample_chain
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
I would like to sample from a posterior distribution which depends on two variables: z and alpha. alpha is a scalar and z is a large vector of hidden variables. I am only interested in the marginal posterior distribution of alpha. When I construct a sample with mcmc.sample_chain it always gives me the full state of the chain for each element of the sample. For large sample sizes and large vectors z this can lead to memory problems. Is there a way to tell sample_chain to only return samples for alpha, but not for z? I have experimented with the trace_fn option, but with that it seems I'm only able to output additional variables like acceptance flags.
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
Begin with the mcmc.sample_chain entry point and its trace_fn behavior described in the issue. Determine how sampling state is selected and define a way to retain alpha without storing z; done means sample_chain can return only the requested state variables while preserving existing tracing behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100