{"action":"created","comment":{"url":"https://api.github.com/repos/fchollet/keras/pulls/comments/46601222","id":46601222,"diff_hunk":"@@ -33,6 +46,25 @@ def __init__(self, **kwargs):\n         if not hasattr(self, 'params'):\n             self.params = []\n \n+    def __call__(self, X):","path":"keras/layers/core.py","position":24,"original_position":24,"commit_id":"9c3060d8ca0142dc79e979f5ba281d9a8590cda6","original_commit_id":"9c3060d8ca0142dc79e979f5ba281d9a8590cda6","user":{"login":"EderSantana","id":3902480,"avatar_url":"https://avatars.githubusercontent.com/u/3902480?v=3","gravatar_id":"","url":"https://api.github.com/users/EderSantana","html_url":"https://github.com/EderSantana","followers_url":"https://api.github.com/users/EderSantana/followers","following_url":"https://api.github.com/users/EderSantana/following{/other_user}","gists_url":"https://api.github.com/users/EderSantana/gists{/gist_id}","starred_url":"https://api.github.com/users/EderSantana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EderSantana/subscriptions","organizations_url":"https://api.github.com/users/EderSantana/orgs","repos_url":"https://api.github.com/users/EderSantana/repos","events_url":"https://api.github.com/users/EderSantana/events{/privacy}","received_events_url":"https://api.github.com/users/EderSantana/received_events","type":"User","site_admin":false},"body":"I added one. An I just linked a working example. If you have some suggestions, please let me know. Also, if you have a better way and want to completely rewrite `__call__` I'm also ok with that.","created_at":"2015-12-03T19:47:20Z","updated_at":"2015-12-03T19:47:20Z","html_url":"https://github.com/fchollet/keras/pull/1162#discussion_r46601222","pull_request_url":"https://api.github.com/repos/fchollet/keras/pulls/1162","_links":{"self":{"href":"https://api.github.com/repos/fchollet/keras/pulls/comments/46601222"},"html":{"href":"https://github.com/fchollet/keras/pull/1162#discussion_r46601222"},"pull_request":{"href":"https://api.github.com/repos/fchollet/keras/pulls/1162"}}},"pull_request":{"url":"https://api.github.com/repos/fchollet/keras/pulls/1162","id":52575620,"html_url":"https://github.com/fchollet/keras/pull/1162","diff_url":"https://github.com/fchollet/keras/pull/1162.diff","patch_url":"https://github.com/fchollet/keras/pull/1162.patch","issue_url":"https://api.github.com/repos/fchollet/keras/issues/1162","number":1162,"state":"open","locked":false,"title":"Add __call__","user":{"login":"EderSantana","id":3902480,"avatar_url":"https://avatars.githubusercontent.com/u/3902480?v=3","gravatar_id":"","url":"https://api.github.com/users/EderSantana","html_url":"https://github.com/EderSantana","followers_url":"https://api.github.com/users/EderSantana/followers","following_url":"https://api.github.com/users/EderSantana/following{/other_user}","gists_url":"https://api.github.com/users/EderSantana/gists{/gist_id}","starred_url":"https://api.github.com/users/EderSantana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EderSantana/subscriptions","organizations_url":"https://api.github.com/users/EderSantana/orgs","repos_url":"https://api.github.com/users/EderSantana/repos","events_url":"https://api.github.com/users/EderSantana/events{/privacy}","received_events_url":"https://api.github.com/users/EderSantana/received_events","type":"User","site_admin":false},"body":"Add a `__call__` method to Layer and Sequential. We can do the following:\r\n```python\r\nX = K.placeholder(ndim=2)\r\nY = model(X)\r\n```\r\n\r\nOne interesting application is where a model is used as an upper layer of another model. In that case, we don't have access to its `get_input`:\r\n```python\r\nencoder = Sequential()\r\ndecoder = Sequential()\r\n\r\nmodel.add(encoder)\r\nmodel.add(decoder)\r\n\r\nX = K.placeholder(ndim=2)\r\nY = decoder(X)\r\n```\r\n\r\nThis code temporally change the value of a specific element of the graph by `X` and call `get_output`. Regardless of the fact that the specific element is a `previous` or `input`. For example, the following code would crash:\r\n\r\n```python\r\nX = decoder.get_input()  # this is not a placeholder Tensor, it is a graph\r\nY = decoder.get_output()\r\nF = function([X], Y)\r\n```\r\n\r\nI also updated some docs. Let me know what you think.\r\n\r\n","created_at":"2015-12-03T18:52:37Z","updated_at":"2015-12-03T19:47:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da8ff7875233f193c35485cf7bea55e6e77bc702","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fchollet/keras/pulls/1162/commits","review_comments_url":"https://api.github.com/repos/fchollet/keras/pulls/1162/comments","review_comment_url":"https://api.github.com/repos/fchollet/keras/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/1162/comments","statuses_url":"https://api.github.com/repos/fchollet/keras/statuses/9c3060d8ca0142dc79e979f5ba281d9a8590cda6","head":{"label":"EderSantana:call","ref":"call","sha":"9c3060d8ca0142dc79e979f5ba281d9a8590cda6","user":{"login":"EderSantana","id":3902480,"avatar_url":"https://avatars.githubusercontent.com/u/3902480?v=3","gravatar_id":"","url":"https://api.github.com/users/EderSantana","html_url":"https://github.com/EderSantana","followers_url":"https://api.github.com/users/EderSantana/followers","following_url":"https://api.github.com/users/EderSantana/following{/other_user}","gists_url":"https://api.github.com/users/EderSantana/gists{/gist_id}","starred_url":"https://api.github.com/users/EderSantana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EderSantana/subscriptions","organizations_url":"https://api.github.com/users/EderSantana/orgs","repos_url":"https://api.github.com/users/EderSantana/repos","events_url":"https://api.github.com/users/EderSantana/events{/privacy}","received_events_url":"https://api.github.com/users/EderSantana/received_events","type":"User","site_admin":false},"repo":{"id":38979951,"name":"keras","full_name":"EderSantana/keras","owner":{"login":"EderSantana","id":3902480,"avatar_url":"https://avatars.githubusercontent.com/u/3902480?v=3","gravatar_id":"","url":"https://api.github.com/users/EderSantana","html_url":"https://github.com/EderSantana","followers_url":"https://api.github.com/users/EderSantana/followers","following_url":"https://api.github.com/users/EderSantana/following{/other_user}","gists_url":"https://api.github.com/users/EderSantana/gists{/gist_id}","starred_url":"https://api.github.com/users/EderSantana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EderSantana/subscriptions","organizations_url":"https://api.github.com/users/EderSantana/orgs","repos_url":"https://api.github.com/users/EderSantana/repos","events_url":"https://api.github.com/users/EderSantana/events{/privacy}","received_events_url":"https://api.github.com/users/EderSantana/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/EderSantana/keras","description":"Theano-based Deep Learning library (convnets, recurrent neural networks, and more).","fork":true,"url":"https://api.github.com/repos/EderSantana/keras","forks_url":"https://api.github.com/repos/EderSantana/keras/forks","keys_url":"https://api.github.com/repos/EderSantana/keras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/EderSantana/keras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/EderSantana/keras/teams","hooks_url":"https://api.github.com/repos/EderSantana/keras/hooks","issue_events_url":"https://api.github.com/repos/EderSantana/keras/issues/events{/number}","events_url":"https://api.github.com/repos/EderSantana/keras/events","assignees_url":"https://api.github.com/repos/EderSantana/keras/assignees{/user}","branches_url":"https://api.github.com/repos/EderSantana/keras/branches{/branch}","tags_url":"https://api.github.com/repos/EderSantana/keras/tags","blobs_url":"https://api.github.com/repos/EderSantana/keras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/EderSantana/keras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/EderSantana/keras/git/refs{/sha}","trees_url":"https://api.github.com/repos/EderSantana/keras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/EderSantana/keras/statuses/{sha}","languages_url":"https://api.github.com/repos/EderSantana/keras/languages","stargazers_url":"https://api.github.com/repos/EderSantana/keras/stargazers","contributors_url":"https://api.github.com/repos/EderSantana/keras/contributors","subscribers_url":"https://api.github.com/repos/EderSantana/keras/subscribers","subscription_url":"https://api.github.com/repos/EderSantana/keras/subscription","commits_url":"https://api.github.com/repos/EderSantana/keras/commits{/sha}","git_commits_url":"https://api.github.com/repos/EderSantana/keras/git/commits{/sha}","comments_url":"https://api.github.com/repos/EderSantana/keras/comments{/number}","issue_comment_url":"https://api.github.com/repos/EderSantana/keras/issues/comments{/number}","contents_url":"https://api.github.com/repos/EderSantana/keras/contents/{+path}","compare_url":"https://api.github.com/repos/EderSantana/keras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/EderSantana/keras/merges","archive_url":"https://api.github.com/repos/EderSantana/keras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/EderSantana/keras/downloads","issues_url":"https://api.github.com/repos/EderSantana/keras/issues{/number}","pulls_url":"https://api.github.com/repos/EderSantana/keras/pulls{/number}","milestones_url":"https://api.github.com/repos/EderSantana/keras/milestones{/number}","notifications_url":"https://api.github.com/repos/EderSantana/keras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/EderSantana/keras/labels{/name}","releases_url":"https://api.github.com/repos/EderSantana/keras/releases{/id}","created_at":"2015-07-12T22:11:46Z","updated_at":"2015-11-18T07:03:39Z","pushed_at":"2015-12-03T19:17:25Z","git_url":"git://github.com/EderSantana/keras.git","ssh_url":"git@github.com:EderSantana/keras.git","clone_url":"https://github.com/EderSantana/keras.git","svn_url":"https://github.com/EderSantana/keras","homepage":"http://keras.io/","size":1337,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"fchollet:master","ref":"master","sha":"bb17fc7af16b0369d24084f0fade3ad102adb10c","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},"repo":{"id":33015583,"name":"keras","full_name":"fchollet/keras","owner":{"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},"private":false,"html_url":"https://github.com/fchollet/keras","description":"Deep Learning library for Python. Convnets, recurrent neural networks, and more. Runs on Theano and TensorFlow.","fork":false,"url":"https://api.github.com/repos/fchollet/keras","forks_url":"https://api.github.com/repos/fchollet/keras/forks","keys_url":"https://api.github.com/repos/fchollet/keras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fchollet/keras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fchollet/keras/teams","hooks_url":"https://api.github.com/repos/fchollet/keras/hooks","issue_events_url":"https://api.github.com/repos/fchollet/keras/issues/events{/number}","events_url":"https://api.github.com/repos/fchollet/keras/events","assignees_url":"https://api.github.com/repos/fchollet/keras/assignees{/user}","branches_url":"https://api.github.com/repos/fchollet/keras/branches{/branch}","tags_url":"https://api.github.com/repos/fchollet/keras/tags","blobs_url":"https://api.github.com/repos/fchollet/keras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fchollet/keras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fchollet/keras/git/refs{/sha}","trees_url":"https://api.github.com/repos/fchollet/keras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fchollet/keras/statuses/{sha}","languages_url":"https://api.github.com/repos/fchollet/keras/languages","stargazers_url":"https://api.github.com/repos/fchollet/keras/stargazers","contributors_url":"https://api.github.com/repos/fchollet/keras/contributors","subscribers_url":"https://api.github.com/repos/fchollet/keras/subscribers","subscription_url":"https://api.github.com/repos/fchollet/keras/subscription","commits_url":"https://api.github.com/repos/fchollet/keras/commits{/sha}","git_commits_url":"https://api.github.com/repos/fchollet/keras/git/commits{/sha}","comments_url":"https://api.github.com/repos/fchollet/keras/comments{/number}","issue_comment_url":"https://api.github.com/repos/fchollet/keras/issues/comments{/number}","contents_url":"https://api.github.com/repos/fchollet/keras/contents/{+path}","compare_url":"https://api.github.com/repos/fchollet/keras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fchollet/keras/merges","archive_url":"https://api.github.com/repos/fchollet/keras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fchollet/keras/downloads","issues_url":"https://api.github.com/repos/fchollet/keras/issues{/number}","pulls_url":"https://api.github.com/repos/fchollet/keras/pulls{/number}","milestones_url":"https://api.github.com/repos/fchollet/keras/milestones{/number}","notifications_url":"https://api.github.com/repos/fchollet/keras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fchollet/keras/labels{/name}","releases_url":"https://api.github.com/repos/fchollet/keras/releases{/id}","created_at":"2015-03-28T00:35:42Z","updated_at":"2015-12-03T17:41:37Z","pushed_at":"2015-12-03T19:25:08Z","git_url":"git://github.com/fchollet/keras.git","ssh_url":"git@github.com:fchollet/keras.git","clone_url":"https://github.com/fchollet/keras.git","svn_url":"https://github.com/fchollet/keras","homepage":"http://keras.io/","size":2472,"stargazers_count":3432,"watchers_count":3432,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":766,"mirror_url":null,"open_issues_count":270,"forks":766,"open_issues":270,"watchers":3432,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fchollet/keras/pulls/1162"},"html":{"href":"https://github.com/fchollet/keras/pull/1162"},"issue":{"href":"https://api.github.com/repos/fchollet/keras/issues/1162"},"comments":{"href":"https://api.github.com/repos/fchollet/keras/issues/1162/comments"},"review_comments":{"href":"https://api.github.com/repos/fchollet/keras/pulls/1162/comments"},"review_comment":{"href":"https://api.github.com/repos/fchollet/keras/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fchollet/keras/pulls/1162/commits"},"statuses":{"href":"https://api.github.com/repos/fchollet/keras/statuses/9c3060d8ca0142dc79e979f5ba281d9a8590cda6"}}}}