-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise informative error message if MvNormal is instantiated without shape
#4379
Comments
I am curious. @lucianopaz How does the observed parameter's shape interact with the distribution shape in PyMC3? |
@Sayam753, the behavior is very inconsistent. When you pass an observed value, the random variables that gets created is a view (i don't remember the op's exact name but it was something like import numpy as np
import pymc3 as pm
with pm.Model():
rv = pm.Normal('a', 0, 1, shape=(3,), observed=np.zeros(4))
print(rv.random().shape) # returns (4,)
print(rv.distribution.random().shape) # returns (3,) Ideally, we should only allow observations that are shaped as a batch of the distribution's shape (we did this in pymc-tfp but didn't back port it to pymc3). |
Makes a lot of sense. Let me spend some time to figure out how this can be done in PyMC3. |
@Sayam753, i don't think it is worth the effort to check it out before v4 |
So, does that depend on the use of RandomVariable Op? (I do not know anything about it) |
What i mean to say is that whatever fix you work this problem now will have to be rethought once the random variables are replaced with an op |
In working in #4373 we decided to require the user to input the shape argument in the init method:
If you don't pass shape you get the default positional argument missing error, which should be informative enough for most Python users. So maybe something like that is sufficient here? |
That's a good idea. Also, I think we need to have a check against passing shape as an empty tuple or |
can I take this up? |
Youre assigned @almostmeenal. Have at it |
I think this one is no longer relevant for V4 |
If so can we close to avoid confusion? |
okay so I'll drop it then
…On 17 Mar 2021, 7:48 PM +0530, Ravin Kumar ***@***.***>, wrote:
If so can we close to avoid confusion?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Setting as wontfix as this may not be necessary after V4. |
Closing this one. I think this issue is no longer relevant following the use of RandomVariables in V4 |
Currently, we have
which isn't a very clear error message. It could be improved to raise an informative error message if
shape
isn't passed. Furthermore, the linevals = pm.MvNormal('vals', mu=mu, chol=chol, observed=data)
from its docstring could be amended to include
shape
Suggested by @Sayam753 here pymc-devs/pymc-examples#11
The text was updated successfully, but these errors were encountered: