tensorflow / tensorflow/probability
NotImplementedError: mean is not implemented: Categorical
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 get the following error
NotImplementedError: mean is not implemented: Categorical
if I execute the following code
import tensorflow_probability as tfp
prob_dist = tfp.distributions.Categorical(probs=[1.0])
print(prob_dist.mean())
I get a similar error, if I attempt to call stddev(). I am using TFP 0.8.0 with TF 2.
The parameters mean and standard deviation are not usually defined for a categorical distribution and this error is due to the fact that tfp.distributions.Categorical inherits from tfp.distributions.Distribution, which defines the mean and stddev methods. PyCharm even suggests the auto-completion of these two methods for the tfp.distributions.Categorical, but this is at least misleading. Maybe tfp.distributions.Categorical should not inherit fromtfp.distributions.Distribution, which should not have those methods in the first place, because not all distributions have a well-defined mean or standard deviation.
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
Reproduce the provided TensorFlow Probability snippet with tfp.distributions.Categorical, then read the linked Categorical and Distribution API documentation. Determine whether the inherited mean() and stddev() behavior should be changed or documented differently; done means the categorical distribution's interface no longer misleadingly offers unsupported statistics, with corresponding behavior or documentation agreed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- api, machine-learning
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100