tensorflow / tensorflow/probability
nan encountered with tfp.substrates.jax.distributions.WishartTriL
Open
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm trying to sample from a Wishart distribution using tfp.substrates.jax and run into nans. I'm not sure why. Here's code to reproduce the error:
import jax.numpy as jnp
from jax import random
import tensorflow_probability as tfp
from jax.config import config
config.update("jax_enable_x64", True)
config.update("jax_debug_nans", True)
dtype = jnp.float64
nc = 13
k = 5
jax_wishart = tfp.substrates.jax.distributions.WishartTriL(df=nc+1, scale_tril=jnp.eye(nc, dtype=dtype))
key = random.PRNGKey(0)
key, subkey = random.split(key)
jax_wishart_samples = jax_wishart.sample(seed=subkey, sample_shape = [10**k])
Thanks in advance.
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 Python reproduction using tfp.substrates.jax.distributions.WishartTriL, jax.numpy, and jax.random. First run it with the shown x64 and debug-nan settings, then trace the WishartTriL sampling path. Done means the example no longer produces NaNs and a regression test covers it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100