{"action":"created","issue":{"url":"https://api.github.com/repos/Theano/Theano/issues/4899","repository_url":"https://api.github.com/repos/Theano/Theano","labels_url":"https://api.github.com/repos/Theano/Theano/issues/4899/labels{/name}","comments_url":"https://api.github.com/repos/Theano/Theano/issues/4899/comments","events_url":"https://api.github.com/repos/Theano/Theano/issues/4899/events","html_url":"https://github.com/Theano/Theano/issues/4899","id":173091226,"number":4899,"title":"when computing grad with many taps `0` is removed twice","user":{"login":"ferrine","id":11705326,"avatar_url":"https://avatars.githubusercontent.com/u/11705326?v=3","gravatar_id":"","url":"https://api.github.com/users/ferrine","html_url":"https://github.com/ferrine","followers_url":"https://api.github.com/users/ferrine/followers","following_url":"https://api.github.com/users/ferrine/following{/other_user}","gists_url":"https://api.github.com/users/ferrine/gists{/gist_id}","starred_url":"https://api.github.com/users/ferrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferrine/subscriptions","organizations_url":"https://api.github.com/users/ferrine/orgs","repos_url":"https://api.github.com/users/ferrine/repos","events_url":"https://api.github.com/users/ferrine/events{/privacy}","received_events_url":"https://api.github.com/users/ferrine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-25T00:51:38Z","updated_at":"2016-08-25T06:44:15Z","closed_at":null,"body":"To reproduce the problem\r\n\r\n```python\r\n# imports\r\nimport pymc3 as pm\r\nimport theano\r\nimport theano.tensor as tt\r\nimport numpy as np\r\n\r\n#data\r\nx = theano.shared(np.random.normal(size=(1000,)), name='x')\r\na = theano.shared(np.ones(3), name='a')\r\nb = theano.shared(np.ones(3), name='b')\r\nevec=tt.constant(np.zeros(3), name='evec')\r\ng = theano.shared(1, name='g')\r\n\r\n\r\ndef lags(x, k=1, axis=-1):\r\n    m = x.shape[0]  # total length\r\n    slices = []\r\n    for i in range(k):\r\n        slices.append(x[k - i - 1:m - i])\r\n    return tt.stack(slices, axis=axis)\r\n\r\ndef gete(x, alpha, beta, gamma, evec, p=3, d=1, q=3):\r\n    L = lags(x, k=p+1)\r\n    dL = tt.extra_ops.diff(L, d, 0)\r\n    y, X = dL[:,0], dL[:,1:]\r\n    etaps = list(-i for i in range(q))\r\n    def e_hat(y, X, *es):\r\n        e = tt.stack(es[:-2])\r\n        return y - tt.dot(X, es[-2]) - tt.dot(e, es[-1])\r\n\r\n    e, _ = theano.scan(fn=e_hat, sequences=[y, X],\r\n                outputs_info=dict(initial=evec, taps=etaps),\r\n                non_sequences=[alpha, beta], strict=True)\r\n    return pm.Normal.dist(0, tt.exp(gamma)).logp(e)\r\n\r\ne = gete(x, a,b,g, evec)\r\ndedw = theano.grad(e.mean(), [a,b,g])\r\n# ValueError: list.remove(x): x not in list\r\n# in theano/scan_module/scan_op.py#783\r\n# because the following happened\r\n# self.tap_array <class 'list'>: [[0, 0, 1, 2], [-1], [-1]]\r\n```\r\nThe first zero was appended here ( to `mitmot_inp_taps` )\r\n`theano/scan_module/scan_op.py#2329` in `Scan.grad`\r\nSecond was appended here ( to `mitmot_inp_taps` )\r\nin loop `for jdx in xrange(len(self.tap_array[idx_tap])):`\r\nwhere `tap_array <class 'list'>: [[0, -1, -2]]`, `idx_tap <int>: 0`\r\n`theano/scan_module/scan_op.py#2343` in `Scan.grad`\r\nafter loop we can see\r\n`mitmot_inp_taps <class 'list'>: [[0, 0, 1, 2]]`\r\nthen more interesting\r\n```python\r\n# `theano/scan_module/scan_op.py#2479` in `Scan.grad`\r\nnew_tap_array = mitmot_inp_taps + [[-1] for k in\r\n                                           xrange(n_sitsot_outs)]\r\ninfo = OrderedDict()\r\n...\r\ninfo['tap_array'] = new_tap_array\r\n...\r\nlocal_op = Scan(inner_gfn_ins, inner_gfn_outs, info)\r\n# it is obvious what's gonna happen soon\r\n```\r\n\r\nIs it a bug or i'm doing wrong?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Theano/Theano/issues/comments/242295139","html_url":"https://github.com/Theano/Theano/issues/4899#issuecomment-242295139","issue_url":"https://api.github.com/repos/Theano/Theano/issues/4899","id":242295139,"user":{"login":"ferrine","id":11705326,"avatar_url":"https://avatars.githubusercontent.com/u/11705326?v=3","gravatar_id":"","url":"https://api.github.com/users/ferrine","html_url":"https://github.com/ferrine","followers_url":"https://api.github.com/users/ferrine/followers","following_url":"https://api.github.com/users/ferrine/following{/other_user}","gists_url":"https://api.github.com/users/ferrine/gists{/gist_id}","starred_url":"https://api.github.com/users/ferrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferrine/subscriptions","organizations_url":"https://api.github.com/users/ferrine/orgs","repos_url":"https://api.github.com/users/ferrine/repos","events_url":"https://api.github.com/users/ferrine/events{/privacy}","received_events_url":"https://api.github.com/users/ferrine/received_events","type":"User","site_admin":false},"created_at":"2016-08-25T06:44:15Z","updated_at":"2016-08-25T06:44:15Z","body":"Error was caused by\r\n`etaps = list(-i for i in range(q))`\r\nIt should be\r\n`etaps = list(-i for i in range(q+1)[1:])`\r\nPlace a debug message for that case please, it was not easy to guess that. Only morning helped."}}
{"actor":{"display_login":"ferrine"}}