{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/1760","repository_url":"https://api.github.com/repos/fchollet/keras","labels_url":"https://api.github.com/repos/fchollet/keras/issues/1760/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/1760/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/1760/events","html_url":"https://github.com/fchollet/keras/issues/1760","id":134772411,"number":1760,"title":"How to have TimeDistributedMerge with Masking","user":{"login":"snakeztc","id":1688939,"avatar_url":"https://avatars.githubusercontent.com/u/1688939?v=3","gravatar_id":"","url":"https://api.github.com/users/snakeztc","html_url":"https://github.com/snakeztc","followers_url":"https://api.github.com/users/snakeztc/followers","following_url":"https://api.github.com/users/snakeztc/following{/other_user}","gists_url":"https://api.github.com/users/snakeztc/gists{/gist_id}","starred_url":"https://api.github.com/users/snakeztc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snakeztc/subscriptions","organizations_url":"https://api.github.com/users/snakeztc/orgs","repos_url":"https://api.github.com/users/snakeztc/repos","events_url":"https://api.github.com/users/snakeztc/events{/privacy}","received_events_url":"https://api.github.com/users/snakeztc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-02-19T05:00:40Z","updated_at":"2016-05-03T14:16:17Z","closed_at":null,"body":"The model that I am trying to build is as follows:\r\n<img width=\"433\" alt=\"screen shot 2016-02-18 at 11 57 07 pm\" src=\"https://cloud.githubusercontent.com/assets/1688939/13166899/627611d0-d69b-11e5-992e-1e66e403160f.png\">\r\n\r\nSo I constructed the following model using Keras:\r\n\r\n        model = Sequential()\r\n        model.add(Embedding(nb_words, hidden_size, mask_zero=True))\r\n        model.add(LSTM(hidden_size, return_sequences=True))\r\n        model.add(Dropout(0.2))\r\n       \r\n        model.add(TimeDistributedMerge(mode='ave'))\r\n        model.add(Dense(hidden_size, init='lecun_uniform'))\r\n        model.add(Activation('relu'))\r\n        model.add(Dropout(0.2))\r\n       \r\n        model.add(Dense(self.domain.actions_num, init='lecun_uniform'))\r\n        model.add(Activation('linear'))\r\n        model.compile(loss='mse', optimizer=\"adam\")\r\n\r\nSo the problem is that I want to use mask_zero because each input sequence have different length. However, I got the error:\r\n**AssertionError: Cannot connect non-masking layer to layer with masked output.**\r\n\r\nSo is it possible to have mean pooling with masking?  Do I need to implement my own layer? Thanks!\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/216542228","html_url":"https://github.com/fchollet/keras/issues/1760#issuecomment-216542228","issue_url":"https://api.github.com/repos/fchollet/keras/issues/1760","id":216542228,"user":{"login":"makagan","id":3691195,"avatar_url":"https://avatars.githubusercontent.com/u/3691195?v=3","gravatar_id":"","url":"https://api.github.com/users/makagan","html_url":"https://github.com/makagan","followers_url":"https://api.github.com/users/makagan/followers","following_url":"https://api.github.com/users/makagan/following{/other_user}","gists_url":"https://api.github.com/users/makagan/gists{/gist_id}","starred_url":"https://api.github.com/users/makagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makagan/subscriptions","organizations_url":"https://api.github.com/users/makagan/orgs","repos_url":"https://api.github.com/users/makagan/repos","events_url":"https://api.github.com/users/makagan/events{/privacy}","received_events_url":"https://api.github.com/users/makagan/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T14:16:17Z","updated_at":"2016-05-03T14:16:17Z","body":"I have a similar problem.  I have tried with TimeDistrubted(Merge(...)),  but have not been able to make it  work.  Is there other news about this?"}}