{"action":"created","comment":{"url":"https://api.github.com/repos/Lasagne/Lasagne/pulls/comments/40782150","id":40782150,"diff_hunk":"@@ -354,3 +356,63 @@ def _meshgrid(height, width):\n     ones = T.ones_like(x_t_flat)\n     grid = T.concatenate([x_t_flat, y_t_flat, ones], axis=0)\n     return grid\n+\n+\n+class ParametricRectifierLayer(Layer):\n+    \"\"\"\n+    lasagne.layers.ParametricRectifierLayer(incoming,\n+    alpha=init.Uniform((0.001, 0.1)), **kwargs)\n+\n+    A layer that applies parametric rectify nonlinearity to its input\n+    following K He, X Zhang et al. (http://arxiv.org/abs/1502.01852):\n+    :math:`\\\\varphi(y_i) = \\\\max(x_i,0) + \\\\alpha_i \\\\min(x_i,0)`\n+\n+    Parameters\n+    ----------\n+    incoming : a :class:`Layer` instance or a tuple\n+        The layer feeding into this layer, or the expected input shape\n+\n+    a : Theano shared variable, numpy array or callable\n+        An initializer for the weights of the layer. If a shared variable or a\n+        numpy array is provided the shape should  be incoming.shape[1:]).\n+        See :meth:`Layer.create_param` for more information.\n+    \"\"\"\n+    def __init__(self, incoming, alpha=init.Uniform((0.001, 0.1)), axes=None,\n+                 **kwargs):\n+        super(ParametricRectifierLayer, self).__init__(incoming, **kwargs)\n+        if axes is None:\n+            # default: the parameters are same across only second axis\n+            # this will do correct thing for both dense operations\n+            # and convolution\n+            axes = (1, )\n+        elif isinstance(axes, int):\n+            axes = (axes,)\n+        shape = [1, ] * len(self.input_shape)\n+        for axis in axes:\n+            shape[axis] = self.input_shape[axis]\n+        self.broadcast = tuple(set(range(len(self.input_shape))) - set(axes))","path":"lasagne/layers/special.py","position":47,"original_position":47,"commit_id":"0f94764139e7bb0e344875f17743a844943b55ff","original_commit_id":"0f94764139e7bb0e344875f17743a844943b55ff","user":{"login":"f0k","id":629706,"avatar_url":"https://avatars.githubusercontent.com/u/629706?v=3","gravatar_id":"","url":"https://api.github.com/users/f0k","html_url":"https://github.com/f0k","followers_url":"https://api.github.com/users/f0k/followers","following_url":"https://api.github.com/users/f0k/following{/other_user}","gists_url":"https://api.github.com/users/f0k/gists{/gist_id}","starred_url":"https://api.github.com/users/f0k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f0k/subscriptions","organizations_url":"https://api.github.com/users/f0k/orgs","repos_url":"https://api.github.com/users/f0k/repos","events_url":"https://api.github.com/users/f0k/events{/privacy}","received_events_url":"https://api.github.com/users/f0k/received_events","type":"User","site_admin":false},"body":"I'd prefer to store `self.axes` (because that's what was given in the constructor) and handle the broadcasting in `get_output_for()`. I think I'd also prefer `alpha` to have fewer dimensions and add them via `dimshuffle` instead of setting them to `1` and adding them via broadcasting. See `BiasLayer` or this prior implementation of a PReLULayer: https://github.com/Lasagne/Lasagne/pull/247/files#diff-bce2cd455789587cf49cbb4b404b5a3dR15\r\nI like the idea of having `axes` specify the axes to untie over, rather than the axes to share over. This seems easier.","created_at":"2015-09-30T11:11:45Z","updated_at":"2015-09-30T11:11:45Z","html_url":"https://github.com/Lasagne/Lasagne/pull/446#discussion_r40782150","pull_request_url":"https://api.github.com/repos/Lasagne/Lasagne/pulls/446","_links":{"self":{"href":"https://api.github.com/repos/Lasagne/Lasagne/pulls/comments/40782150"},"html":{"href":"https://github.com/Lasagne/Lasagne/pull/446#discussion_r40782150"},"pull_request":{"href":"https://api.github.com/repos/Lasagne/Lasagne/pulls/446"}}},"pull_request":{"url":"https://api.github.com/repos/Lasagne/Lasagne/pulls/446","id":46348485,"html_url":"https://github.com/Lasagne/Lasagne/pull/446","diff_url":"https://github.com/Lasagne/Lasagne/pull/446.diff","patch_url":"https://github.com/Lasagne/Lasagne/pull/446.patch","issue_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/446","number":446,"state":"open","locked":false,"title":"ParametricRectifyLayer","user":{"login":"Botev","id":1889878,"avatar_url":"https://avatars.githubusercontent.com/u/1889878?v=3","gravatar_id":"","url":"https://api.github.com/users/Botev","html_url":"https://github.com/Botev","followers_url":"https://api.github.com/users/Botev/followers","following_url":"https://api.github.com/users/Botev/following{/other_user}","gists_url":"https://api.github.com/users/Botev/gists{/gist_id}","starred_url":"https://api.github.com/users/Botev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Botev/subscriptions","organizations_url":"https://api.github.com/users/Botev/orgs","repos_url":"https://api.github.com/users/Botev/repos","events_url":"https://api.github.com/users/Botev/events{/privacy}","received_events_url":"https://api.github.com/users/Botev/received_events","type":"User","site_admin":false},"body":"So I need to add tests. Plus additionally I'm not sure if I'm not missing with the shape of the parameter, if someone can give me a feedback if there are any hidden corners when it won't broadcast correctly.","created_at":"2015-09-30T00:14:05Z","updated_at":"2015-09-30T11:11:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"43f500db092552a1d96fdc286fe78b43de31ecda","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Lasagne/Lasagne/pulls/446/commits","review_comments_url":"https://api.github.com/repos/Lasagne/Lasagne/pulls/446/comments","review_comment_url":"https://api.github.com/repos/Lasagne/Lasagne/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/446/comments","statuses_url":"https://api.github.com/repos/Lasagne/Lasagne/statuses/0f94764139e7bb0e344875f17743a844943b55ff","head":{"label":"Botev:prelu","ref":"prelu","sha":"0f94764139e7bb0e344875f17743a844943b55ff","user":{"login":"Botev","id":1889878,"avatar_url":"https://avatars.githubusercontent.com/u/1889878?v=3","gravatar_id":"","url":"https://api.github.com/users/Botev","html_url":"https://github.com/Botev","followers_url":"https://api.github.com/users/Botev/followers","following_url":"https://api.github.com/users/Botev/following{/other_user}","gists_url":"https://api.github.com/users/Botev/gists{/gist_id}","starred_url":"https://api.github.com/users/Botev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Botev/subscriptions","organizations_url":"https://api.github.com/users/Botev/orgs","repos_url":"https://api.github.com/users/Botev/repos","events_url":"https://api.github.com/users/Botev/events{/privacy}","received_events_url":"https://api.github.com/users/Botev/received_events","type":"User","site_admin":false},"repo":{"id":42042675,"name":"Lasagne","full_name":"Botev/Lasagne","owner":{"login":"Botev","id":1889878,"avatar_url":"https://avatars.githubusercontent.com/u/1889878?v=3","gravatar_id":"","url":"https://api.github.com/users/Botev","html_url":"https://github.com/Botev","followers_url":"https://api.github.com/users/Botev/followers","following_url":"https://api.github.com/users/Botev/following{/other_user}","gists_url":"https://api.github.com/users/Botev/gists{/gist_id}","starred_url":"https://api.github.com/users/Botev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Botev/subscriptions","organizations_url":"https://api.github.com/users/Botev/orgs","repos_url":"https://api.github.com/users/Botev/repos","events_url":"https://api.github.com/users/Botev/events{/privacy}","received_events_url":"https://api.github.com/users/Botev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Botev/Lasagne","description":"Lightweight library to build and train neural networks in Theano","fork":true,"url":"https://api.github.com/repos/Botev/Lasagne","forks_url":"https://api.github.com/repos/Botev/Lasagne/forks","keys_url":"https://api.github.com/repos/Botev/Lasagne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Botev/Lasagne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Botev/Lasagne/teams","hooks_url":"https://api.github.com/repos/Botev/Lasagne/hooks","issue_events_url":"https://api.github.com/repos/Botev/Lasagne/issues/events{/number}","events_url":"https://api.github.com/repos/Botev/Lasagne/events","assignees_url":"https://api.github.com/repos/Botev/Lasagne/assignees{/user}","branches_url":"https://api.github.com/repos/Botev/Lasagne/branches{/branch}","tags_url":"https://api.github.com/repos/Botev/Lasagne/tags","blobs_url":"https://api.github.com/repos/Botev/Lasagne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Botev/Lasagne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Botev/Lasagne/git/refs{/sha}","trees_url":"https://api.github.com/repos/Botev/Lasagne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Botev/Lasagne/statuses/{sha}","languages_url":"https://api.github.com/repos/Botev/Lasagne/languages","stargazers_url":"https://api.github.com/repos/Botev/Lasagne/stargazers","contributors_url":"https://api.github.com/repos/Botev/Lasagne/contributors","subscribers_url":"https://api.github.com/repos/Botev/Lasagne/subscribers","subscription_url":"https://api.github.com/repos/Botev/Lasagne/subscription","commits_url":"https://api.github.com/repos/Botev/Lasagne/commits{/sha}","git_commits_url":"https://api.github.com/repos/Botev/Lasagne/git/commits{/sha}","comments_url":"https://api.github.com/repos/Botev/Lasagne/comments{/number}","issue_comment_url":"https://api.github.com/repos/Botev/Lasagne/issues/comments{/number}","contents_url":"https://api.github.com/repos/Botev/Lasagne/contents/{+path}","compare_url":"https://api.github.com/repos/Botev/Lasagne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Botev/Lasagne/merges","archive_url":"https://api.github.com/repos/Botev/Lasagne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Botev/Lasagne/downloads","issues_url":"https://api.github.com/repos/Botev/Lasagne/issues{/number}","pulls_url":"https://api.github.com/repos/Botev/Lasagne/pulls{/number}","milestones_url":"https://api.github.com/repos/Botev/Lasagne/milestones{/number}","notifications_url":"https://api.github.com/repos/Botev/Lasagne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Botev/Lasagne/labels{/name}","releases_url":"https://api.github.com/repos/Botev/Lasagne/releases{/id}","created_at":"2015-09-07T09:03:17Z","updated_at":"2015-09-07T09:03:17Z","pushed_at":"2015-09-30T10:12:33Z","git_url":"git://github.com/Botev/Lasagne.git","ssh_url":"git@github.com:Botev/Lasagne.git","clone_url":"https://github.com/Botev/Lasagne.git","svn_url":"https://github.com/Botev/Lasagne","homepage":"http://lasagne.readthedocs.org/","size":1830,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"Lasagne:master","ref":"master","sha":"eab3d9ad302980b24c6b945575252940ca53bbf4","user":{"login":"Lasagne","id":11752110,"avatar_url":"https://avatars.githubusercontent.com/u/11752110?v=3","gravatar_id":"","url":"https://api.github.com/users/Lasagne","html_url":"https://github.com/Lasagne","followers_url":"https://api.github.com/users/Lasagne/followers","following_url":"https://api.github.com/users/Lasagne/following{/other_user}","gists_url":"https://api.github.com/users/Lasagne/gists{/gist_id}","starred_url":"https://api.github.com/users/Lasagne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lasagne/subscriptions","organizations_url":"https://api.github.com/users/Lasagne/orgs","repos_url":"https://api.github.com/users/Lasagne/repos","events_url":"https://api.github.com/users/Lasagne/events{/privacy}","received_events_url":"https://api.github.com/users/Lasagne/received_events","type":"Organization","site_admin":false},"repo":{"id":23924195,"name":"Lasagne","full_name":"Lasagne/Lasagne","owner":{"login":"Lasagne","id":11752110,"avatar_url":"https://avatars.githubusercontent.com/u/11752110?v=3","gravatar_id":"","url":"https://api.github.com/users/Lasagne","html_url":"https://github.com/Lasagne","followers_url":"https://api.github.com/users/Lasagne/followers","following_url":"https://api.github.com/users/Lasagne/following{/other_user}","gists_url":"https://api.github.com/users/Lasagne/gists{/gist_id}","starred_url":"https://api.github.com/users/Lasagne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lasagne/subscriptions","organizations_url":"https://api.github.com/users/Lasagne/orgs","repos_url":"https://api.github.com/users/Lasagne/repos","events_url":"https://api.github.com/users/Lasagne/events{/privacy}","received_events_url":"https://api.github.com/users/Lasagne/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Lasagne/Lasagne","description":"Lightweight library to build and train neural networks in Theano","fork":false,"url":"https://api.github.com/repos/Lasagne/Lasagne","forks_url":"https://api.github.com/repos/Lasagne/Lasagne/forks","keys_url":"https://api.github.com/repos/Lasagne/Lasagne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lasagne/Lasagne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lasagne/Lasagne/teams","hooks_url":"https://api.github.com/repos/Lasagne/Lasagne/hooks","issue_events_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/events{/number}","events_url":"https://api.github.com/repos/Lasagne/Lasagne/events","assignees_url":"https://api.github.com/repos/Lasagne/Lasagne/assignees{/user}","branches_url":"https://api.github.com/repos/Lasagne/Lasagne/branches{/branch}","tags_url":"https://api.github.com/repos/Lasagne/Lasagne/tags","blobs_url":"https://api.github.com/repos/Lasagne/Lasagne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lasagne/Lasagne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lasagne/Lasagne/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lasagne/Lasagne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lasagne/Lasagne/statuses/{sha}","languages_url":"https://api.github.com/repos/Lasagne/Lasagne/languages","stargazers_url":"https://api.github.com/repos/Lasagne/Lasagne/stargazers","contributors_url":"https://api.github.com/repos/Lasagne/Lasagne/contributors","subscribers_url":"https://api.github.com/repos/Lasagne/Lasagne/subscribers","subscription_url":"https://api.github.com/repos/Lasagne/Lasagne/subscription","commits_url":"https://api.github.com/repos/Lasagne/Lasagne/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lasagne/Lasagne/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lasagne/Lasagne/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lasagne/Lasagne/contents/{+path}","compare_url":"https://api.github.com/repos/Lasagne/Lasagne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lasagne/Lasagne/merges","archive_url":"https://api.github.com/repos/Lasagne/Lasagne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lasagne/Lasagne/downloads","issues_url":"https://api.github.com/repos/Lasagne/Lasagne/issues{/number}","pulls_url":"https://api.github.com/repos/Lasagne/Lasagne/pulls{/number}","milestones_url":"https://api.github.com/repos/Lasagne/Lasagne/milestones{/number}","notifications_url":"https://api.github.com/repos/Lasagne/Lasagne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lasagne/Lasagne/labels{/name}","releases_url":"https://api.github.com/repos/Lasagne/Lasagne/releases{/id}","created_at":"2014-09-11T15:31:41Z","updated_at":"2015-09-29T21:23:09Z","pushed_at":"2015-09-30T11:07:28Z","git_url":"git://github.com/Lasagne/Lasagne.git","ssh_url":"git@github.com:Lasagne/Lasagne.git","clone_url":"https://github.com/Lasagne/Lasagne.git","svn_url":"https://github.com/Lasagne/Lasagne","homepage":"http://lasagne.readthedocs.org/","size":7436,"stargazers_count":1076,"watchers_count":1076,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":266,"mirror_url":null,"open_issues_count":65,"forks":266,"open_issues":65,"watchers":1076,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Lasagne/Lasagne/pulls/446"},"html":{"href":"https://github.com/Lasagne/Lasagne/pull/446"},"issue":{"href":"https://api.github.com/repos/Lasagne/Lasagne/issues/446"},"comments":{"href":"https://api.github.com/repos/Lasagne/Lasagne/issues/446/comments"},"review_comments":{"href":"https://api.github.com/repos/Lasagne/Lasagne/pulls/446/comments"},"review_comment":{"href":"https://api.github.com/repos/Lasagne/Lasagne/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Lasagne/Lasagne/pulls/446/commits"},"statuses":{"href":"https://api.github.com/repos/Lasagne/Lasagne/statuses/0f94764139e7bb0e344875f17743a844943b55ff"}}}}