{"action":"created","issue":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/842","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/842/labels{/name}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/842/comments","events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/842/events","html_url":"https://github.com/pymc-devs/pymc3/issues/842","id":109159817,"number":842,"title":"Erroneous dimension mis-match error","user":{"login":"fonnesbeck","id":81476,"avatar_url":"https://avatars.githubusercontent.com/u/81476?v=3","gravatar_id":"","url":"https://api.github.com/users/fonnesbeck","html_url":"https://github.com/fonnesbeck","followers_url":"https://api.github.com/users/fonnesbeck/followers","following_url":"https://api.github.com/users/fonnesbeck/following{/other_user}","gists_url":"https://api.github.com/users/fonnesbeck/gists{/gist_id}","starred_url":"https://api.github.com/users/fonnesbeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fonnesbeck/subscriptions","organizations_url":"https://api.github.com/users/fonnesbeck/orgs","repos_url":"https://api.github.com/users/fonnesbeck/repos","events_url":"https://api.github.com/users/fonnesbeck/events{/privacy}","received_events_url":"https://api.github.com/users/fonnesbeck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-09-30T19:15:45Z","updated_at":"2015-11-02T14:43:24Z","closed_at":null,"body":"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 a `shape` argument to the likelihood also does not fix the problem, nor does removing `find_map`. Passing a scalar as data resolves the issue.\r\n\r\n```python\r\nimport pymc3 as pm\r\nimport numpy as np\r\n\r\ndata = [6.0,12.0,12.0,46.0,5.0,11.0,11.0,39.0,4.0,10.0,25.0,11.0,8.0,5.0,10.0,2.0,30.0,21.0]\r\n\r\nwith pm.Model() as model:\r\n    alpha = pm.Uniform('alpha', lower=0.1, upper=100)\r\n    mu = pm.Uniform('mu', lower=0.1, upper=100)\r\n\r\n    y_pred = pm.NegativeBinomial('y_pred', mu=mu, alpha=alpha)\r\n\r\n    y_est = pm.NegativeBinomial('y_est', \r\n                                mu=mu, \r\n                                alpha=alpha, \r\n                                observed=data)\r\n\r\n    start = pm.find_MAP()\r\n\r\n    step = pm.NUTS()\r\n    trace = pm.sample(2000, step, start=start, progressbar=True)\r\n```\r\n\r\nHere's the error.\r\n\r\n\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n/Users/fonnescj/anaconda3/lib/python3.4/site-packages/theano/compile/function_module.py in __call__(self, *args, **kwargs)\r\n    839         try:\r\n--> 840             outputs = self.fn()\r\n    841         except Exception:\r\n\r\nValueError: Input dimension mis-match. (input[0].shape[0] = 1, input[4].shape[0] = 18)\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-4-899599b91d18> in <module>()\r\n     15                                 observed=data, shape=len(data))\r\n     16 \r\n---> 17     start = pm.find_MAP()\r\n     18 \r\n     19     step = pm.NUTS()\r\n\r\n/Users/fonnescj/Github/pymc3/pymc3/tuning/starting.py in find_MAP(start, vars, fmin, return_raw, disp, model, *args, **kwargs)\r\n     79     if 'fprime' in getargspec(fmin).args:\r\n     80         r = fmin(logp_o, bij.map(\r\n---> 81             start), fprime=grad_logp_o, disp=disp, *args, **kwargs)\r\n     82     else:\r\n     83         r = fmin(logp_o, bij.map(start), disp=disp, *args, **kwargs)\r\n\r\n/Users/fonnescj/anaconda3/lib/python3.4/site-packages/scipy/optimize/optimize.py in fmin_bfgs(f, x0, fprime, args, gtol, norm, epsilon, maxiter, full_output, disp, retall, callback)\r\n    787             'return_all': retall}\r\n    788 \r\n--> 789     res = _minimize_bfgs(f, x0, args, fprime, callback=callback, **opts)\r\n    790 \r\n    791     if full_output:\r\n\r\n/Users/fonnescj/anaconda3/lib/python3.4/site-packages/scipy/optimize/optimize.py in _minimize_bfgs(fun, x0, args, jac, callback, gtol, norm, eps, maxiter, disp, return_all, **unknown_options)\r\n    841     else:\r\n    842         grad_calls, myfprime = wrap_function(fprime, args)\r\n--> 843     gfk = myfprime(x0)\r\n    844     k = 0\r\n    845     N = len(x0)\r\n\r\n/Users/fonnescj/anaconda3/lib/python3.4/site-packages/scipy/optimize/optimize.py in function_wrapper(*wrapper_args)\r\n    283     def function_wrapper(*wrapper_args):\r\n    284         ncalls[0] += 1\r\n--> 285         return function(*(wrapper_args + args))\r\n    286 \r\n    287     return ncalls, function_wrapper\r\n\r\n/Users/fonnescj/Github/pymc3/pymc3/tuning/starting.py in grad_logp_o(point)\r\n     74 \r\n     75     def grad_logp_o(point):\r\n---> 76         return nan_to_num(-dlogp(point))\r\n     77 \r\n     78     # Check to see if minimization function actually uses the gradient\r\n\r\n/Users/fonnescj/Github/pymc3/pymc3/blocking.py in __call__(self, x)\r\n    117 \r\n    118     def __call__(self, x):\r\n--> 119         return self.fa(self.fb(x))\r\n\r\n/Users/fonnescj/Github/pymc3/pymc3/model.py in __call__(self, state)\r\n    397 \r\n    398     def __call__(self, state):\r\n--> 399         return self.f(**state)\r\n    400 \r\n    401 class LoosePointFunc(object):\r\n\r\n/Users/fonnescj/anaconda3/lib/python3.4/site-packages/theano/compile/function_module.py in __call__(self, *args, **kwargs)\r\n    849                         self.fn.nodes[self.fn.position_of_error],\r\n    850                         self.fn.thunks[self.fn.position_of_error],\r\n--> 851                         storage_map=self.fn.storage_map)\r\n    852                 else:\r\n    853                     # For the c linker We don't have access from\r\n\r\n/Users/fonnescj/anaconda3/lib/python3.4/site-packages/theano/gof/link.py in raise_with_op(node, thunk, exc_info, storage_map)\r\n    312         # extra long error message in that case.\r\n    313         pass\r\n--> 314     reraise(exc_type, exc_value, exc_trace)\r\n    315 \r\n    316 \r\n\r\n/Users/fonnescj/anaconda3/lib/python3.4/site-packages/six.py in reraise(tp, value, tb)\r\n    656             value = tp()\r\n    657         if value.__traceback__ is not tb:\r\n--> 658             raise value.with_traceback(tb)\r\n    659         raise value\r\n    660 \r\n\r\n/Users/fonnescj/anaconda3/lib/python3.4/site-packages/theano/compile/function_module.py in __call__(self, *args, **kwargs)\r\n    838         t0_fn = time.time()\r\n    839         try:\r\n--> 840             outputs = self.fn()\r\n    841         except Exception:\r\n    842             if hasattr(self.fn, 'position_of_error'):\r\n\r\nValueError: Input dimension mis-match. (input[0].shape[0] = 1, input[4].shape[0] = 18)\r\nApply node that caused the error: Elemwise{Composite{Switch(i0, i1, Switch(i2, Switch(i3, i1, i4), i1))}}(TensorConstant{(1,) of 0}, TensorConstant{(1,) of 0}, Elemwise{mul,no_inplace}.0, InplaceDimShuffle{x}.0, TensorConstant{[  6.  12... 30.  21.]})\r\nToposort index: 36\r\nInputs types: [TensorType(int8, vector), TensorType(int8, (True,)), TensorType(int8, (True,)), TensorType(int8, (True,)), TensorType(float64, vector)]\r\nInputs shapes: [(1,), (1,), (1,), (1,), (18,)]\r\nInputs strides: [(1,), (1,), (1,), (1,), (8,)]\r\nInputs values: [array([0], dtype=int8), array([0], dtype=int8), array([1], dtype=int8), array([0], dtype=int8), 'not shown']\r\nOutputs clients: [[Sum{acc_dtype=float64}(Elemwise{Composite{Switch(i0, i1, Switch(i2, Switch(i3, i1, i4), i1))}}.0)]]\r\n\r\nHINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.\r\nHINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.\r\n```"},"comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments/153036175","html_url":"https://github.com/pymc-devs/pymc3/issues/842#issuecomment-153036175","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/842","id":153036175,"user":{"login":"fonnesbeck","id":81476,"avatar_url":"https://avatars.githubusercontent.com/u/81476?v=3","gravatar_id":"","url":"https://api.github.com/users/fonnesbeck","html_url":"https://github.com/fonnesbeck","followers_url":"https://api.github.com/users/fonnesbeck/followers","following_url":"https://api.github.com/users/fonnesbeck/following{/other_user}","gists_url":"https://api.github.com/users/fonnesbeck/gists{/gist_id}","starred_url":"https://api.github.com/users/fonnesbeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fonnesbeck/subscriptions","organizations_url":"https://api.github.com/users/fonnesbeck/orgs","repos_url":"https://api.github.com/users/fonnesbeck/repos","events_url":"https://api.github.com/users/fonnesbeck/events{/privacy}","received_events_url":"https://api.github.com/users/fonnesbeck/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T14:43:24Z","updated_at":"2015-11-02T14:43:24Z","body":"The problem is with the switch statement in `logpow`. I think I have dealt with it. Please test."}}