{"action":"closed","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/160","labels_url":"https://api.github.com/repos/fchollet/keras/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/160/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/160/events","html_url":"https://github.com/fchollet/keras/issues/160","id":80825265,"number":160,"title":"Stacking multiple LSTM layers yields an error","user":{"login":"Tener","id":158712,"avatar_url":"https://avatars.githubusercontent.com/u/158712?v=3","gravatar_id":"","url":"https://api.github.com/users/Tener","html_url":"https://github.com/Tener","followers_url":"https://api.github.com/users/Tener/followers","following_url":"https://api.github.com/users/Tener/following{/other_user}","gists_url":"https://api.github.com/users/Tener/gists{/gist_id}","starred_url":"https://api.github.com/users/Tener/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tener/subscriptions","organizations_url":"https://api.github.com/users/Tener/orgs","repos_url":"https://api.github.com/users/Tener/repos","events_url":"https://api.github.com/users/Tener/events{/privacy}","received_events_url":"https://api.github.com/users/Tener/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-26T06:50:27Z","updated_at":"2015-05-26T16:03:33Z","closed_at":"2015-05-26T16:03:33Z","body":"I tried to create a network with multiple LSTM layers. No matter what I try this or similar attempts will yield an error:\r\n\r\n```python\r\nfrom keras.models import Sequential\r\nfrom keras.layers.core import Dense, Dropout, Activation\r\nfrom keras.layers.embeddings import Embedding\r\nfrom keras.layers.recurrent import LSTM\r\n\r\nnb_chars = 26 # a..z\r\nnb_nodes = 50\r\n\r\nmodel = Sequential()\r\nmodel.add(Embedding(nb_chars, nb_chars))\r\nmodel.add(LSTM(nb_chars, nb_nodes, activation='sigmoid', inner_activation='hard_sigmoid'))\r\nmodel.add(Dropout(0.5))\r\nmodel.add(LSTM(nb_nodes, nb_nodes, activation='sigmoid', inner_activation='hard_sigmoid'))\r\nmodel.add(Dropout(0.5))\r\nmodel.add(Dense(nb_nodes, nb_chars))\r\nmodel.add(Activation('sigmoid'))\r\nmodel.add(Dropout(0.5))\r\n\r\nmodel.compile(loss='binary_crossentropy', optimizer='rmsprop')\r\n```\r\n\r\nError:\r\n```\r\nTraceback (most recent call last):\r\n  File \"test.py\", line 21, in <module>\r\n    model.compile(loss='binary_crossentropy', optimizer='rmsprop')\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/models.py\", line 71, in compile\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/models.py\", line 155, in get_output\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/core.py\", line 115, in get_output\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/core.py\", line 27, in get_input\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/core.py\", line 140, in get_output\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/core.py\", line 27, in get_input\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/core.py\", line 233, in get_output\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/core.py\", line 27, in get_input\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/core.py\", line 115, in get_output\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/core.py\", line 27, in get_input\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Keras-0.0.1-py3.4.egg/keras/layers/recurrent.py\", line 338, in get_output\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Theano-0.7.0-py3.4.egg/theano/tensor/var.py\", line 341, in dimshuffle\r\n    pattern)\r\n  File \"/home/tener/.local/lib/python3.4/site-packages/Theano-0.7.0-py3.4.egg/theano/tensor/elemwise.py\", line 141, in __init__\r\n    (i, j, len(input_broadcastable)))\r\nValueError: new_order[2] is 2, but the input only has 2 axes.\r\n```\r\n\r\nIf I replace one of LSTM with, say, Dense, it will work. I cannot figure out why - according to the documentation the inputs and outputs of both should match?"}}