{"action":"created","issue":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/778","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/778/labels{/name}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/778/comments","events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/778/events","html_url":"https://github.com/pymc-devs/pymc3/issues/778","id":90982824,"number":778,"title":"AssertionError with theano","user":{"login":"hadim","id":528003,"avatar_url":"https://avatars.githubusercontent.com/u/528003?v=3","gravatar_id":"","url":"https://api.github.com/users/hadim","html_url":"https://github.com/hadim","followers_url":"https://api.github.com/users/hadim/followers","following_url":"https://api.github.com/users/hadim/following{/other_user}","gists_url":"https://api.github.com/users/hadim/gists{/gist_id}","starred_url":"https://api.github.com/users/hadim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadim/subscriptions","organizations_url":"https://api.github.com/users/hadim/orgs","repos_url":"https://api.github.com/users/hadim/repos","events_url":"https://api.github.com/users/hadim/events{/privacy}","received_events_url":"https://api.github.com/users/hadim/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-06-25T14:36:47Z","updated_at":"2015-06-25T19:41:49Z","closed_at":"2015-06-25T15:34:32Z","body":"I am trying to port the first pymc2 example from the book \"Bayesian Methods for Hackers\" to pymc3 but I have the following error:\r\n\r\n```python\r\ncount_data = np.loadtxt(\"/home/hadim/txtdata.csv\")\r\n\r\n@theano.compile.ops.as_op(itypes=[t.dscalar, t.dscalar, t.dscalar], otypes=[t.dvector])\r\ndef lambda_(tau, lambda_1, lambda_2):\r\n    out = np.zeros(n_count_data)\r\n    out[:tau] = lambda_1  # lambda before tau is lambda1\r\n    out[tau:] = lambda_2  # lambda after (and including) tau is lambda2\r\n    return True\r\n\r\nalpha = 1.0 / count_data.mean()  # Recall count_data is the variable that holds our txt counts\r\n\r\nwith pm.Model() as model:\r\n\r\n    lambda_1 = pm.Exponential(\"lambda_1\", alpha)\r\n    lambda_2 = pm.Exponential(\"lambda_2\", alpha)\r\n\r\n    tau = pm.DiscreteUniform(\"tau\", lower=0, upper=n_count_data)\r\n        \r\n    observation = pm.Poisson(\"observation\", mu=lambda_(tau, lambda_1, lambda_2), observed=count_data)\r\n```\r\n\r\n```\r\n\r\n---------------------------------------------------------------------------\r\nAssertionError                            Traceback (most recent call last)\r\n<ipython-input-47-33fca4e63eeb> in <module>()\r\n     17     tau = pm.DiscreteUniform(\"tau\", lower=0, upper=n_count_data)\r\n     18 \r\n---> 19     observation = pm.Poisson(\"observation\", mu=lambda_(tau, lambda_1, lambda_2), observed=count_data)\r\n\r\n/home/hadim/local/conda/envs/st/lib/python3.4/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)\r\n    505         \"\"\"\r\n    506         return_list = kwargs.pop('return_list', False)\r\n--> 507         node = self.make_node(*inputs, **kwargs)\r\n    508 \r\n    509         if config.compute_test_value != 'off':\r\n\r\n/home/hadim/local/conda/envs/st/lib/python3.4/site-packages/theano/compile/ops.py in make_node(self, *inputs)\r\n    487     def make_node(self, *inputs):\r\n    488         assert len(inputs) == len(self.itypes)\r\n--> 489         assert all(inp.type == it for inp, it in zip(inputs, self.itypes))\r\n    490         return theano.Apply(self, inputs, [o() for o in self.otypes])\r\n    491 \r\n\r\nAssertionError: \r\n```\r\n\r\nAny idea ?"},"comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments/115373268","html_url":"https://github.com/pymc-devs/pymc3/issues/778#issuecomment-115373268","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/778","id":115373268,"user":{"login":"jsalvatier","id":270513,"avatar_url":"https://avatars.githubusercontent.com/u/270513?v=3","gravatar_id":"","url":"https://api.github.com/users/jsalvatier","html_url":"https://github.com/jsalvatier","followers_url":"https://api.github.com/users/jsalvatier/followers","following_url":"https://api.github.com/users/jsalvatier/following{/other_user}","gists_url":"https://api.github.com/users/jsalvatier/gists{/gist_id}","starred_url":"https://api.github.com/users/jsalvatier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsalvatier/subscriptions","organizations_url":"https://api.github.com/users/jsalvatier/orgs","repos_url":"https://api.github.com/users/jsalvatier/repos","events_url":"https://api.github.com/users/jsalvatier/events{/privacy}","received_events_url":"https://api.github.com/users/jsalvatier/received_events","type":"User","site_admin":false},"created_at":"2015-06-25T19:41:49Z","updated_at":"2015-06-25T19:41:49Z","body":"Ahh, yes, the issue with `tau` is definitely it. The issue seems to be that `days = np.zeros(len(count_data))` is wrong. It should be `days =np.arange(len(count_data))`. Days is the index of the day."}}