tensorflow / tensorflow/probability
RelaxedOneHotCategorical has incorrect output for logits under 1 when logits are type of float32
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 was trying out the RelaxedOneHotCategorical function on tensorfloa_probability version 0.19.0. The following code gives me the incorrect distribution.
from tensorflow_probability.substrates import jax as tfp
temperature = 0.5
p = [0.1, 0.5, 0.4]
dist = tfp.distributions.RelaxedOneHotCategorical(temperature, logits=p)
from jax import random
dist.sample(seed=random.PRNGkey(0))
The expected behavior is "the 2nd class is the most likely be the largest component in samples". However, I got the reverse probability instead.
Array([0.9872344, 0.00204739, 0.01071812], dtype=float32)
This behavior disappears when the logits are > 1, or if we cast p to be float16.
Is this expected?
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
Start with the provided Python reproducer for tfp.distributions.RelaxedOneHotCategorical using the JAX substrate and float32 logits. Inspect the RelaxedOneHotCategorical sampling entry point and compare float32 behavior with the float16 and logits-greater-than-one cases; done means the reported output is explained or corrected and the expected class probabilities are preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100