{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/2505","repository_url":"https://api.github.com/repos/fchollet/keras","labels_url":"https://api.github.com/repos/fchollet/keras/issues/2505/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/2505/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/2505/events","html_url":"https://github.com/fchollet/keras/issues/2505","id":151009198,"number":2505,"title":"Is there anyway to pass one-hot binary vector as input and embed it?","user":{"login":"code-ball","id":17498315,"avatar_url":"https://avatars.githubusercontent.com/u/17498315?v=3","gravatar_id":"","url":"https://api.github.com/users/code-ball","html_url":"https://github.com/code-ball","followers_url":"https://api.github.com/users/code-ball/followers","following_url":"https://api.github.com/users/code-ball/following{/other_user}","gists_url":"https://api.github.com/users/code-ball/gists{/gist_id}","starred_url":"https://api.github.com/users/code-ball/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-ball/subscriptions","organizations_url":"https://api.github.com/users/code-ball/orgs","repos_url":"https://api.github.com/users/code-ball/repos","events_url":"https://api.github.com/users/code-ball/events{/privacy}","received_events_url":"https://api.github.com/users/code-ball/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-25T23:54:11Z","updated_at":"2016-04-26T00:14:26Z","closed_at":null,"body":"I have a situation where I want to pass 1-hot vectors as input and then embed it into lower dimension. \r\n\r\nFor example, I have single feature input vector like this: \r\n\r\n> **a** = \r\n> [0,\r\n>  1,\r\n>  0,\r\n>  2,\r\n>  3,\r\n>  3,\r\n> ]\r\n\r\nAs one can see, there are three classes and 6 samples, hence it's one-hot encoding will be:\r\n\r\n> **b** = \r\n> [1 0 0 0,\r\n>  0 1 0 0,\r\n>  1 0 0 0,\r\n>  0 0 1 0,\r\n>  0 0 0 1,\r\n>  0 0 0 1\r\n> ]\r\n\r\nI want to pass **b** as input to the model and then embed it using an embedding layer.\r\nCurrent embedding seems to only support sequence of categorical values as input and not the one-hot vectors. \r\nIn fact, I am able to successfully pass **a** and get an embedding with something like below:\r\n\r\n```python\r\na =  Input(shape=(1,), dtype='int32', name = 'input1')\r\nem = Embedding(output_dim=3,input_dim=4,input_length=1) (a)\r\n\r\n```\r\nBut I cannot see how can I modify this to pass **b** as input instead of **a**.\r\nPlease let me know if there is any way to work around this.\r\n\r\nThanks\r\n \r\n"},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/214569525","html_url":"https://github.com/fchollet/keras/issues/2505#issuecomment-214569525","issue_url":"https://api.github.com/repos/fchollet/keras/issues/2505","id":214569525,"user":{"login":"code-ball","id":17498315,"avatar_url":"https://avatars.githubusercontent.com/u/17498315?v=3","gravatar_id":"","url":"https://api.github.com/users/code-ball","html_url":"https://github.com/code-ball","followers_url":"https://api.github.com/users/code-ball/followers","following_url":"https://api.github.com/users/code-ball/following{/other_user}","gists_url":"https://api.github.com/users/code-ball/gists{/gist_id}","starred_url":"https://api.github.com/users/code-ball/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-ball/subscriptions","organizations_url":"https://api.github.com/users/code-ball/orgs","repos_url":"https://api.github.com/users/code-ball/repos","events_url":"https://api.github.com/users/code-ball/events{/privacy}","received_events_url":"https://api.github.com/users/code-ball/received_events","type":"User","site_admin":false},"created_at":"2016-04-26T00:14:26Z","updated_at":"2016-04-26T00:14:26Z","body":"@braingineer: Thanks  for a quick response. While I understand your idea, I don't think I get it fully. Specifically, I did not understand the part of  multiply the embedding matrix by the binary feature vectors. Do I need to write my own embedding layer for that? Or do you mean it can be done with existing API?\r\n\r\nIf it is later, can you provide code snippet exemplifying how to do it in above case?\r\n\r\nThanks"}}