-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Erroneous dimension mis-match error #842
Comments
I'm not sure if this is useful whilst debugging/investigating - but if the observed dataset contains the value zero, the model executes without error.
|
wtf. This is all real weird. Especially the zero thing. On Thu, Oct 1, 2015 at 8:06 AM Mark Regan notifications@github.com wrote:
|
I have just run into a similar issue on OS X, Python 2.7. model = Model()
obs = np.array([16, 18, 22, 25, 27])
with model:
theta = pymc3.Uniform('theta', lower=0, upper=1)
n = pymc3.DiscreteUniform('n', lower=1, upper=500)
k = pymc3.Binomial("k", n=n, p=theta, shape=1,
observed=obs)
start = find_MAP()
step = pymc3.NUTS()
trace = sample(1000, step, start=start,
progressbar = True) Produces a similar error:
Moreover, the error DOES mysteriously go away if I change one of the observed values to 0! I suspect this is the same issue. |
The above issue now returns a different error. This might be useful for debugging.
This is similar to another bug referenced recently: #850 Versions: |
Update: there are two issues being referred to here.
An ipython notebook with this issue can be found here: https://github.com/markdregan/Bayesian-Modelling-in-Python/blob/master/Section%203.%20Hierarchical%20modelling.ipynb |
How about if you cast your observed data to a Numpy array? I've seen lists cause trouble before, but not for awhile. |
Casting to numpy array doesn't resolve the issue. The error trace is the same. |
This is odd indeed, I suspect a bug in Here is the minimal code to replicate stand-alone: import pymc3 as pm
import numpy as np
with pm.Model() as model:
alpha = pm.Uniform('alpha', lower=0, upper=100)
mu = pm.Uniform('mu', lower=0, upper=100)
data = [34.0, 27.0, 3.0, 17.0, 17.0, 29.0, 53.0]
y_est = pm.NegativeBinomial('y_est', mu=mu, alpha=alpha, observed=np.asarray(data, dtype='int16'))
start = pm.find_MAP() Btw. @markdregan your project looks very interesting. |
The |
Actually, looks like only one expression gets evaluated by Theano, so disregard the above. |
I can confirm that this also occurs with the Poisson. |
The problem is with the switch statement in |
I tested with the original NB of @markdregan and everything worked well. |
Yes - can confirm issue is resolved. Thought I responded here. Thank you all for digging in to the issue and resolving. |
As reported by another user, the following simple model fails on OS X and Python 3. It appears to be complaining about the size of the
observed
argument for the NegativeBinomial, which should not be happening. Changing to another distribution (e.g. Poisson) does not change this. Adding ashape
argument to the likelihood also does not fix the problem, nor does removingfind_map
. Passing a scalar as data resolves the issue.Here's the error.
The text was updated successfully, but these errors were encountered: