{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/520","labels_url":"https://api.github.com/repos/fchollet/keras/issues/520/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/520/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/520/events","html_url":"https://github.com/fchollet/keras/issues/520","id":100252071,"number":520,"title":"Embedding fail on Graph","user":{"login":"ipod825","id":1246394,"avatar_url":"https://avatars.githubusercontent.com/u/1246394?v=3","gravatar_id":"","url":"https://api.github.com/users/ipod825","html_url":"https://github.com/ipod825","followers_url":"https://api.github.com/users/ipod825/followers","following_url":"https://api.github.com/users/ipod825/following{/other_user}","gists_url":"https://api.github.com/users/ipod825/gists{/gist_id}","starred_url":"https://api.github.com/users/ipod825/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipod825/subscriptions","organizations_url":"https://api.github.com/users/ipod825/orgs","repos_url":"https://api.github.com/users/ipod825/repos","events_url":"https://api.github.com/users/ipod825/events{/privacy}","received_events_url":"https://api.github.com/users/ipod825/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-11T08:08:22Z","updated_at":"2015-08-11T08:10:41Z","closed_at":"2015-08-11T08:10:41Z","body":"I failed to add an <code>Embedding</code> layer on <code>Graph</code> model.\r\n\r\nHere's the code that works:\r\n<pre><code>\r\nfrom keras.models import Sequential, Graph\r\nfrom keras.layers.core import Dense\r\nfrom keras.layers.embeddings import Embedding\r\nlookup = Sequential()\r\nlookup.add(Embedding(2, 1))\r\nlookup.compile(loss='binary_crossentropy', optimizer='sgd')\r\n</pre></code>\r\n\r\nAnd here's the code that fails:\r\n<pre><code>\r\nfrom keras.models import Sequential, Graph\r\nfrom keras.layers.core import Dense\r\nfrom keras.layers.embeddings import Embedding\r\nmodel = Graph()\r\nmodel.add_input('input')\r\nmodel.add_node(Embedding(2,1), input='input', name='emb')\r\nmodel.add_output(name='output', input='emb')\r\nmodel.compile('sgd', {'output':'binary_crossentropy'})\r\n</pre></code>\r\n\r\nThe error message is:\r\n<pre><code>\r\nTraceback (most recent call last):\r\n  File \"./test.py\", line 16, in <module>\r\n    model.compile('sgd', {'output':'binary_crossentropy'})\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/models.py\", line 525, in compile\r\n    y_train = output.get_output(True)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/layers/embeddings.py\", line 62, in get_output\r\n    out = self.W[X]\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/tensor/var.py\", line 474, in __getitem__\r\n    return self.take(args[axis], axis)\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/tensor/var.py\", line 506, in take\r\n    return theano.tensor.subtensor.take(self, indices, axis, mode)\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/tensor/subtensor.py\", line 2290, in take\r\n    return take(a, indices.flatten(), axis, mode).reshape(shape, ndim)\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/tensor/subtensor.py\", line 2268, in take\r\n    return advanced_subtensor1(a, indices)\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/gof/op.py\", line 509, in __call__\r\n    node = self.make_node(*inputs, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/tensor/subtensor.py\", line 1608, in make_node\r\n    raise TypeError('index must be integers')\r\nTypeError: index must be integers\r\n</pre></code>\r\n\r\nBleeding edge theao is used."},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/129758481","html_url":"https://github.com/fchollet/keras/issues/520#issuecomment-129758481","issue_url":"https://api.github.com/repos/fchollet/keras/issues/520","id":129758481,"user":{"login":"fchollet","id":710255,"avatar_url":"https://avatars.githubusercontent.com/u/710255?v=3","gravatar_id":"","url":"https://api.github.com/users/fchollet","html_url":"https://github.com/fchollet","followers_url":"https://api.github.com/users/fchollet/followers","following_url":"https://api.github.com/users/fchollet/following{/other_user}","gists_url":"https://api.github.com/users/fchollet/gists{/gist_id}","starred_url":"https://api.github.com/users/fchollet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fchollet/subscriptions","organizations_url":"https://api.github.com/users/fchollet/orgs","repos_url":"https://api.github.com/users/fchollet/repos","events_url":"https://api.github.com/users/fchollet/events{/privacy}","received_events_url":"https://api.github.com/users/fchollet/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T08:10:41Z","updated_at":"2015-08-11T08:10:41Z","body":"> add_input(name, ndim=2, dtype='int')\r\n\r\nwill tell the Graph to expect an integer matrix input."}}