{"action":"created","comment":{"url":"https://api.github.com/repos/pfnet/chainer/pulls/comments/35180628","id":35180628,"diff_hunk":"@@ -0,0 +1,47 @@\n+from chainer import cuda\n+from chainer import function\n+import numpy\n+\n+\n+class ClippedReLU(function.Function):\n+\n+    \"\"\"clipped ReLU function. clipped ReLU is written as below,\n+\n+    :math:`ClippedReLU(x, z) = min{max{0,x},z}`\n+    z is a parameter to cap return value of ReLU.\n+\n+    \"\"\"\n+\n+    def __init__(self, z):\n+        self.cap = z\n+\n+    def forward_cpu(self, x):\n+        return numpy.minimum(numpy.maximum(0, x[0]), self.cap),\n+\n+    def backward_cpu(self, x, gy):\n+        return gy[0] * (0 < x[0]) * (x[0] < self.cap),\n+\n+    def forward_gpu(self, x):\n+        return cuda.gpuarray.minimum(cuda.gpuarray.maximum(0, x[0]), self.cap),\n+\n+    def backward_gpu(self, x, gy):\n+        gx = cuda.empty_like(x[0])\n+        cuda.elementwise(\n+            'float* gx, const float* x, const float* gy, const float z',\n+            'gx[i] = ((x[i] > 0) and (x[i] < z))? gy[i] : 0',\n+            'relu_bwd')(gx, x[0], gy[0], self.cap)\n+        return gx,\n+\n+\n+def clipped_relu(x, z=20):\n+    \"\"\"Clipped Rectifier Unit function :math:`CReLU(x, z) = min{max{0,x},z}`\n+\n+    Args:\n+        x (~chainer.Variable): Input variable.\n+        z (integer): clipping value. (default = 20)","path":"chainer/functions/clipped_relu.py","position":41,"original_position":41,"commit_id":"97f6f3a0f076c93c3087694908e3f2c7268878c5","original_commit_id":"97f6f3a0f076c93c3087694908e3f2c7268878c5","user":{"login":"unnonouno","id":740680,"avatar_url":"https://avatars.githubusercontent.com/u/740680?v=3","gravatar_id":"","url":"https://api.github.com/users/unnonouno","html_url":"https://github.com/unnonouno","followers_url":"https://api.github.com/users/unnonouno/followers","following_url":"https://api.github.com/users/unnonouno/following{/other_user}","gists_url":"https://api.github.com/users/unnonouno/gists{/gist_id}","starred_url":"https://api.github.com/users/unnonouno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unnonouno/subscriptions","organizations_url":"https://api.github.com/users/unnonouno/orgs","repos_url":"https://api.github.com/users/unnonouno/repos","events_url":"https://api.github.com/users/unnonouno/events{/privacy}","received_events_url":"https://api.github.com/users/unnonouno/received_events","type":"User","site_admin":false},"body":"s/integer/int/","created_at":"2015-07-22T04:31:48Z","updated_at":"2015-07-22T04:31:48Z","html_url":"https://github.com/pfnet/chainer/pull/245#discussion_r35180628","pull_request_url":"https://api.github.com/repos/pfnet/chainer/pulls/245","_links":{"self":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/comments/35180628"},"html":{"href":"https://github.com/pfnet/chainer/pull/245#discussion_r35180628"},"pull_request":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/245"}}},"pull_request":{"url":"https://api.github.com/repos/pfnet/chainer/pulls/245","id":40451613,"html_url":"https://github.com/pfnet/chainer/pull/245","diff_url":"https://github.com/pfnet/chainer/pull/245.diff","patch_url":"https://github.com/pfnet/chainer/pull/245.patch","issue_url":"https://api.github.com/repos/pfnet/chainer/issues/245","number":245,"state":"open","locked":false,"title":"Add clipped Rectifier Linear Unit","user":{"login":"jnishi","id":836541,"avatar_url":"https://avatars.githubusercontent.com/u/836541?v=3","gravatar_id":"","url":"https://api.github.com/users/jnishi","html_url":"https://github.com/jnishi","followers_url":"https://api.github.com/users/jnishi/followers","following_url":"https://api.github.com/users/jnishi/following{/other_user}","gists_url":"https://api.github.com/users/jnishi/gists{/gist_id}","starred_url":"https://api.github.com/users/jnishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnishi/subscriptions","organizations_url":"https://api.github.com/users/jnishi/orgs","repos_url":"https://api.github.com/users/jnishi/repos","events_url":"https://api.github.com/users/jnishi/events{/privacy}","received_events_url":"https://api.github.com/users/jnishi/received_events","type":"User","site_admin":false},"body":"I impremented clipped Rectifier Linear Unit, which is written as below.\r\n```ClippedReLU(x, z) = min{max{0,x},z}.```\r\n `z` is a parameter to cap return value of ReLU.","created_at":"2015-07-21T12:30:48Z","updated_at":"2015-07-22T04:31:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d768d38628d3f7d17a6e3fd0feede06e7b80b8d2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pfnet/chainer/pulls/245/commits","review_comments_url":"https://api.github.com/repos/pfnet/chainer/pulls/245/comments","review_comment_url":"https://api.github.com/repos/pfnet/chainer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pfnet/chainer/issues/245/comments","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/97f6f3a0f076c93c3087694908e3f2c7268878c5","head":{"label":"jnishi:add-clipped-relu","ref":"add-clipped-relu","sha":"97f6f3a0f076c93c3087694908e3f2c7268878c5","user":{"login":"jnishi","id":836541,"avatar_url":"https://avatars.githubusercontent.com/u/836541?v=3","gravatar_id":"","url":"https://api.github.com/users/jnishi","html_url":"https://github.com/jnishi","followers_url":"https://api.github.com/users/jnishi/followers","following_url":"https://api.github.com/users/jnishi/following{/other_user}","gists_url":"https://api.github.com/users/jnishi/gists{/gist_id}","starred_url":"https://api.github.com/users/jnishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnishi/subscriptions","organizations_url":"https://api.github.com/users/jnishi/orgs","repos_url":"https://api.github.com/users/jnishi/repos","events_url":"https://api.github.com/users/jnishi/events{/privacy}","received_events_url":"https://api.github.com/users/jnishi/received_events","type":"User","site_admin":false},"repo":{"id":37111431,"name":"chainer","full_name":"jnishi/chainer","owner":{"login":"jnishi","id":836541,"avatar_url":"https://avatars.githubusercontent.com/u/836541?v=3","gravatar_id":"","url":"https://api.github.com/users/jnishi","html_url":"https://github.com/jnishi","followers_url":"https://api.github.com/users/jnishi/followers","following_url":"https://api.github.com/users/jnishi/following{/other_user}","gists_url":"https://api.github.com/users/jnishi/gists{/gist_id}","starred_url":"https://api.github.com/users/jnishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnishi/subscriptions","organizations_url":"https://api.github.com/users/jnishi/orgs","repos_url":"https://api.github.com/users/jnishi/repos","events_url":"https://api.github.com/users/jnishi/events{/privacy}","received_events_url":"https://api.github.com/users/jnishi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jnishi/chainer","description":"A flexible framework of neural networks","fork":true,"url":"https://api.github.com/repos/jnishi/chainer","forks_url":"https://api.github.com/repos/jnishi/chainer/forks","keys_url":"https://api.github.com/repos/jnishi/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jnishi/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jnishi/chainer/teams","hooks_url":"https://api.github.com/repos/jnishi/chainer/hooks","issue_events_url":"https://api.github.com/repos/jnishi/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/jnishi/chainer/events","assignees_url":"https://api.github.com/repos/jnishi/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/jnishi/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/jnishi/chainer/tags","blobs_url":"https://api.github.com/repos/jnishi/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jnishi/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jnishi/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/jnishi/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jnishi/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/jnishi/chainer/languages","stargazers_url":"https://api.github.com/repos/jnishi/chainer/stargazers","contributors_url":"https://api.github.com/repos/jnishi/chainer/contributors","subscribers_url":"https://api.github.com/repos/jnishi/chainer/subscribers","subscription_url":"https://api.github.com/repos/jnishi/chainer/subscription","commits_url":"https://api.github.com/repos/jnishi/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/jnishi/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/jnishi/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/jnishi/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/jnishi/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/jnishi/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jnishi/chainer/merges","archive_url":"https://api.github.com/repos/jnishi/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jnishi/chainer/downloads","issues_url":"https://api.github.com/repos/jnishi/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/jnishi/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/jnishi/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/jnishi/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jnishi/chainer/labels{/name}","releases_url":"https://api.github.com/repos/jnishi/chainer/releases{/id}","created_at":"2015-06-09T05:06:28Z","updated_at":"2015-06-09T05:06:28Z","pushed_at":"2015-07-22T02:32:34Z","git_url":"git://github.com/jnishi/chainer.git","ssh_url":"git@github.com:jnishi/chainer.git","clone_url":"https://github.com/jnishi/chainer.git","svn_url":"https://github.com/jnishi/chainer","homepage":"http://chainer.org","size":6389,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pfnet:master","ref":"master","sha":"2ec241169d83a21e265645d3b23f3ec0c13bd2b3","user":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"repo":{"id":36914478,"name":"chainer","full_name":"pfnet/chainer","owner":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pfnet/chainer","description":"A flexible framework of neural networks for deep learning","fork":false,"url":"https://api.github.com/repos/pfnet/chainer","forks_url":"https://api.github.com/repos/pfnet/chainer/forks","keys_url":"https://api.github.com/repos/pfnet/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pfnet/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pfnet/chainer/teams","hooks_url":"https://api.github.com/repos/pfnet/chainer/hooks","issue_events_url":"https://api.github.com/repos/pfnet/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/pfnet/chainer/events","assignees_url":"https://api.github.com/repos/pfnet/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/pfnet/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/pfnet/chainer/tags","blobs_url":"https://api.github.com/repos/pfnet/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pfnet/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pfnet/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/pfnet/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/pfnet/chainer/languages","stargazers_url":"https://api.github.com/repos/pfnet/chainer/stargazers","contributors_url":"https://api.github.com/repos/pfnet/chainer/contributors","subscribers_url":"https://api.github.com/repos/pfnet/chainer/subscribers","subscription_url":"https://api.github.com/repos/pfnet/chainer/subscription","commits_url":"https://api.github.com/repos/pfnet/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/pfnet/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/pfnet/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/pfnet/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/pfnet/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/pfnet/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pfnet/chainer/merges","archive_url":"https://api.github.com/repos/pfnet/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pfnet/chainer/downloads","issues_url":"https://api.github.com/repos/pfnet/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/pfnet/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/pfnet/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/pfnet/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pfnet/chainer/labels{/name}","releases_url":"https://api.github.com/repos/pfnet/chainer/releases{/id}","created_at":"2015-06-05T05:50:37Z","updated_at":"2015-07-21T16:41:39Z","pushed_at":"2015-07-22T02:32:34Z","git_url":"git://github.com/pfnet/chainer.git","ssh_url":"git@github.com:pfnet/chainer.git","clone_url":"https://github.com/pfnet/chainer.git","svn_url":"https://github.com/pfnet/chainer","homepage":"http://chainer.org","size":9709,"stargazers_count":565,"watchers_count":565,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":77,"mirror_url":null,"open_issues_count":64,"forks":77,"open_issues":64,"watchers":565,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/245"},"html":{"href":"https://github.com/pfnet/chainer/pull/245"},"issue":{"href":"https://api.github.com/repos/pfnet/chainer/issues/245"},"comments":{"href":"https://api.github.com/repos/pfnet/chainer/issues/245/comments"},"review_comments":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/245/comments"},"review_comment":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/245/commits"},"statuses":{"href":"https://api.github.com/repos/pfnet/chainer/statuses/97f6f3a0f076c93c3087694908e3f2c7268878c5"}}}}