{"action":"created","comment":{"url":"https://api.github.com/repos/mila-udem/blocks/pulls/comments/43958354","id":43958354,"diff_hunk":"@@ -117,13 +118,82 @@ def test_max_pooling():\n                        dtype=theano.config.floatX)\n     assert_allclose(func(x_val),\n                     numpy.ones((batch_size, num_channels,\n-                                x_size / pool_size + 1,\n-                                y_size / pool_size + 1)))\n+                                x_size / pool_size,\n+                                y_size / pool_size)))\n     pool.input_dim = (x_size, y_size)\n     pool.get_dim('output') == (num_channels, x_size / pool_size + 1,\n                                y_size / pool_size + 1)\n \n \n+def test_max_pooling_ignore_border_true():\n+    x = tensor.tensor4('x')\n+    brick = MaxPooling((3, 4), ignore_border=True)\n+    y = brick.apply(x)\n+    out = y.eval({x: numpy.zeros((8, 3, 10, 13), dtype=theano.config.floatX)})\n+    assert out.shape == (8, 3, 3, 3)\n+\n+\n+def test_max_pooling_ignore_border_false():\n+    x = tensor.tensor4('x')\n+    brick = MaxPooling((5, 7), ignore_border=False)\n+    y = brick.apply(x)\n+    out = y.eval({x: numpy.zeros((4, 6, 12, 15), dtype=theano.config.floatX)})\n+    assert out.shape == (4, 6, 3, 3)\n+\n+\n+def test_max_pooling_padding():\n+    x = tensor.tensor4('x')\n+    brick = MaxPooling((6, 2), padding=(3, 1), ignore_border=True)\n+    y = brick.apply(x)\n+    out = y.eval({x: numpy.zeros((2, 3, 6, 10), dtype=theano.config.floatX)})\n+    assert out.shape == (2, 3, 2, 6)\n+\n+\n+def test_average_pooling():\n+    x = tensor.tensor4('x')\n+    brick = AveragePooling((2, 2))\n+    y = brick.apply(x)\n+    tmp = numpy.arange(16, dtype=theano.config.floatX).reshape(1, 1, 4, 4)\n+    x_ = numpy.tile(tmp, [2, 3, 1, 1])\n+    out = y.eval({x: x_})\n+    assert_allclose(\n+        out - numpy.array([[10 / 4., 18 / 4.], [42 / 4., 50 / 4.]]),\n+        numpy.zeros_like(out))\n+\n+\n+def test_average_pooling_inc_padding():\n+    x = tensor.tensor4('x')\n+    brick = AveragePooling((2, 2), ignore_border=True, padding=(1, 1),\n+                           include_padding=True)\n+    y = brick.apply(x)\n+    output = y.eval({x: 3 * numpy.ones((1, 1, 2, 2),\n+                                       dtype=theano.config.floatX)})\n+    expected_out = numpy.array([0.75, 0.75, 0.75, 0.75]).reshape(1, 1, 2, 2)\n+    assert_allclose(expected_out, output)\n+\n+\n+def test_average_pooling_exc_padding():\n+    x = tensor.tensor4('x')\n+    brick = AveragePooling((2, 2), ignore_border=True, padding=(1, 1),\n+                           include_padding=False)\n+    y = brick.apply(x)\n+    x_ = 3 * numpy.ones((1, 1, 2, 2), dtype=theano.config.floatX)\n+    output = y.eval({x: x_})\n+    assert_allclose(x_, output)\n+\n+\n+def test_pooling_works_in_convolutional_sequence():","path":"tests/bricks/test_conv.py","position":80,"original_position":80,"commit_id":"b87ad2eab6d9f106dbde61e0735af1c333cbc5dd","original_commit_id":"b87ad2eab6d9f106dbde61e0735af1c333cbc5dd","user":{"login":"dwf","id":60206,"avatar_url":"https://avatars.githubusercontent.com/u/60206?v=3","gravatar_id":"","url":"https://api.github.com/users/dwf","html_url":"https://github.com/dwf","followers_url":"https://api.github.com/users/dwf/followers","following_url":"https://api.github.com/users/dwf/following{/other_user}","gists_url":"https://api.github.com/users/dwf/gists{/gist_id}","starred_url":"https://api.github.com/users/dwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwf/subscriptions","organizations_url":"https://api.github.com/users/dwf/orgs","repos_url":"https://api.github.com/users/dwf/repos","events_url":"https://api.github.com/users/dwf/events{/privacy}","received_events_url":"https://api.github.com/users/dwf/received_events","type":"User","site_admin":false},"body":"CCW ticket? :)","created_at":"2015-11-04T23:44:50Z","updated_at":"2015-11-04T23:44:50Z","html_url":"https://github.com/mila-udem/blocks/pull/899#discussion_r43958354","pull_request_url":"https://api.github.com/repos/mila-udem/blocks/pulls/899","_links":{"self":{"href":"https://api.github.com/repos/mila-udem/blocks/pulls/comments/43958354"},"html":{"href":"https://github.com/mila-udem/blocks/pull/899#discussion_r43958354"},"pull_request":{"href":"https://api.github.com/repos/mila-udem/blocks/pulls/899"}}},"pull_request":{"url":"https://api.github.com/repos/mila-udem/blocks/pulls/899","id":49488033,"html_url":"https://github.com/mila-udem/blocks/pull/899","diff_url":"https://github.com/mila-udem/blocks/pull/899.diff","patch_url":"https://github.com/mila-udem/blocks/pull/899.patch","issue_url":"https://api.github.com/repos/mila-udem/blocks/issues/899","number":899,"state":"open","locked":false,"title":"Convolutional network pooling improvements","user":{"login":"dwf","id":60206,"avatar_url":"https://avatars.githubusercontent.com/u/60206?v=3","gravatar_id":"","url":"https://api.github.com/users/dwf","html_url":"https://github.com/dwf","followers_url":"https://api.github.com/users/dwf/followers","following_url":"https://api.github.com/users/dwf/following{/other_user}","gists_url":"https://api.github.com/users/dwf/gists{/gist_id}","starred_url":"https://api.github.com/users/dwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwf/subscriptions","organizations_url":"https://api.github.com/users/dwf/orgs","repos_url":"https://api.github.com/users/dwf/repos","events_url":"https://api.github.com/users/dwf/events{/privacy}","received_events_url":"https://api.github.com/users/dwf/received_events","type":"User","site_admin":false},"body":"This pull request accomplishes a few things:\r\n* Most notably, an AveragePooling Brick (mentioned in #257), accomplished by refactoring MaxPooling into a base Pooling Brick and MaxPooling and AveragePooling descendants.\r\n  * Tests for AveragePooling's two modes w.r.t. padding.\r\n* More complete wrapping of Theano's `max_pool_2d` function (which, bizarrely, also handles average pooling)\r\n  * Basic tests for these.\r\n* Improvements to ConvolutionalSequence that let you use MaxPooling (and AveragePooling) without ConvolutionalLayer, and make the interface a bit more coherent (i.e. not directly querying `num_filters` for the number of output channels, which is not always the case e.g. with a convolutional maxout layer or something)\r\n* **Change the default `ignore_border` mode to `False`**, while exposing it in an option, with a warning in the docs that modifying it (with certain step configurations) can force computation onto the CPU.\r\n\r\nFixes #894, and an item in #257 that should be crossed off there.","created_at":"2015-11-02T21:28:14Z","updated_at":"2015-11-04T23:44:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ce6d13ce19f2cc30d347acb7cace843ac5646348","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mila-udem/blocks/pulls/899/commits","review_comments_url":"https://api.github.com/repos/mila-udem/blocks/pulls/899/comments","review_comment_url":"https://api.github.com/repos/mila-udem/blocks/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mila-udem/blocks/issues/899/comments","statuses_url":"https://api.github.com/repos/mila-udem/blocks/statuses/b87ad2eab6d9f106dbde61e0735af1c333cbc5dd","head":{"label":"dwf:conv_improvements","ref":"conv_improvements","sha":"b87ad2eab6d9f106dbde61e0735af1c333cbc5dd","user":{"login":"dwf","id":60206,"avatar_url":"https://avatars.githubusercontent.com/u/60206?v=3","gravatar_id":"","url":"https://api.github.com/users/dwf","html_url":"https://github.com/dwf","followers_url":"https://api.github.com/users/dwf/followers","following_url":"https://api.github.com/users/dwf/following{/other_user}","gists_url":"https://api.github.com/users/dwf/gists{/gist_id}","starred_url":"https://api.github.com/users/dwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwf/subscriptions","organizations_url":"https://api.github.com/users/dwf/orgs","repos_url":"https://api.github.com/users/dwf/repos","events_url":"https://api.github.com/users/dwf/events{/privacy}","received_events_url":"https://api.github.com/users/dwf/received_events","type":"User","site_admin":false},"repo":{"id":28125354,"name":"blocks","full_name":"dwf/blocks","owner":{"login":"dwf","id":60206,"avatar_url":"https://avatars.githubusercontent.com/u/60206?v=3","gravatar_id":"","url":"https://api.github.com/users/dwf","html_url":"https://github.com/dwf","followers_url":"https://api.github.com/users/dwf/followers","following_url":"https://api.github.com/users/dwf/following{/other_user}","gists_url":"https://api.github.com/users/dwf/gists{/gist_id}","starred_url":"https://api.github.com/users/dwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwf/subscriptions","organizations_url":"https://api.github.com/users/dwf/orgs","repos_url":"https://api.github.com/users/dwf/repos","events_url":"https://api.github.com/users/dwf/events{/privacy}","received_events_url":"https://api.github.com/users/dwf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dwf/blocks","description":"","fork":true,"url":"https://api.github.com/repos/dwf/blocks","forks_url":"https://api.github.com/repos/dwf/blocks/forks","keys_url":"https://api.github.com/repos/dwf/blocks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dwf/blocks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dwf/blocks/teams","hooks_url":"https://api.github.com/repos/dwf/blocks/hooks","issue_events_url":"https://api.github.com/repos/dwf/blocks/issues/events{/number}","events_url":"https://api.github.com/repos/dwf/blocks/events","assignees_url":"https://api.github.com/repos/dwf/blocks/assignees{/user}","branches_url":"https://api.github.com/repos/dwf/blocks/branches{/branch}","tags_url":"https://api.github.com/repos/dwf/blocks/tags","blobs_url":"https://api.github.com/repos/dwf/blocks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dwf/blocks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dwf/blocks/git/refs{/sha}","trees_url":"https://api.github.com/repos/dwf/blocks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dwf/blocks/statuses/{sha}","languages_url":"https://api.github.com/repos/dwf/blocks/languages","stargazers_url":"https://api.github.com/repos/dwf/blocks/stargazers","contributors_url":"https://api.github.com/repos/dwf/blocks/contributors","subscribers_url":"https://api.github.com/repos/dwf/blocks/subscribers","subscription_url":"https://api.github.com/repos/dwf/blocks/subscription","commits_url":"https://api.github.com/repos/dwf/blocks/commits{/sha}","git_commits_url":"https://api.github.com/repos/dwf/blocks/git/commits{/sha}","comments_url":"https://api.github.com/repos/dwf/blocks/comments{/number}","issue_comment_url":"https://api.github.com/repos/dwf/blocks/issues/comments{/number}","contents_url":"https://api.github.com/repos/dwf/blocks/contents/{+path}","compare_url":"https://api.github.com/repos/dwf/blocks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dwf/blocks/merges","archive_url":"https://api.github.com/repos/dwf/blocks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dwf/blocks/downloads","issues_url":"https://api.github.com/repos/dwf/blocks/issues{/number}","pulls_url":"https://api.github.com/repos/dwf/blocks/pulls{/number}","milestones_url":"https://api.github.com/repos/dwf/blocks/milestones{/number}","notifications_url":"https://api.github.com/repos/dwf/blocks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dwf/blocks/labels{/name}","releases_url":"https://api.github.com/repos/dwf/blocks/releases{/id}","created_at":"2014-12-17T06:56:35Z","updated_at":"2015-03-13T19:51:16Z","pushed_at":"2015-11-04T19:50:07Z","git_url":"git://github.com/dwf/blocks.git","ssh_url":"git@github.com:dwf/blocks.git","clone_url":"https://github.com/dwf/blocks.git","svn_url":"https://github.com/dwf/blocks","homepage":null,"size":4073,"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":"mila-udem:master","ref":"master","sha":"414519d813cfc72960a63caa7808be8e2e064fbf","user":{"login":"mila-udem","id":11724251,"avatar_url":"https://avatars.githubusercontent.com/u/11724251?v=3","gravatar_id":"","url":"https://api.github.com/users/mila-udem","html_url":"https://github.com/mila-udem","followers_url":"https://api.github.com/users/mila-udem/followers","following_url":"https://api.github.com/users/mila-udem/following{/other_user}","gists_url":"https://api.github.com/users/mila-udem/gists{/gist_id}","starred_url":"https://api.github.com/users/mila-udem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mila-udem/subscriptions","organizations_url":"https://api.github.com/users/mila-udem/orgs","repos_url":"https://api.github.com/users/mila-udem/repos","events_url":"https://api.github.com/users/mila-udem/events{/privacy}","received_events_url":"https://api.github.com/users/mila-udem/received_events","type":"Organization","site_admin":false},"repo":{"id":24829371,"name":"blocks","full_name":"mila-udem/blocks","owner":{"login":"mila-udem","id":11724251,"avatar_url":"https://avatars.githubusercontent.com/u/11724251?v=3","gravatar_id":"","url":"https://api.github.com/users/mila-udem","html_url":"https://github.com/mila-udem","followers_url":"https://api.github.com/users/mila-udem/followers","following_url":"https://api.github.com/users/mila-udem/following{/other_user}","gists_url":"https://api.github.com/users/mila-udem/gists{/gist_id}","starred_url":"https://api.github.com/users/mila-udem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mila-udem/subscriptions","organizations_url":"https://api.github.com/users/mila-udem/orgs","repos_url":"https://api.github.com/users/mila-udem/repos","events_url":"https://api.github.com/users/mila-udem/events{/privacy}","received_events_url":"https://api.github.com/users/mila-udem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mila-udem/blocks","description":"A Theano framework for building and training neural networks","fork":false,"url":"https://api.github.com/repos/mila-udem/blocks","forks_url":"https://api.github.com/repos/mila-udem/blocks/forks","keys_url":"https://api.github.com/repos/mila-udem/blocks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mila-udem/blocks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mila-udem/blocks/teams","hooks_url":"https://api.github.com/repos/mila-udem/blocks/hooks","issue_events_url":"https://api.github.com/repos/mila-udem/blocks/issues/events{/number}","events_url":"https://api.github.com/repos/mila-udem/blocks/events","assignees_url":"https://api.github.com/repos/mila-udem/blocks/assignees{/user}","branches_url":"https://api.github.com/repos/mila-udem/blocks/branches{/branch}","tags_url":"https://api.github.com/repos/mila-udem/blocks/tags","blobs_url":"https://api.github.com/repos/mila-udem/blocks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mila-udem/blocks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mila-udem/blocks/git/refs{/sha}","trees_url":"https://api.github.com/repos/mila-udem/blocks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mila-udem/blocks/statuses/{sha}","languages_url":"https://api.github.com/repos/mila-udem/blocks/languages","stargazers_url":"https://api.github.com/repos/mila-udem/blocks/stargazers","contributors_url":"https://api.github.com/repos/mila-udem/blocks/contributors","subscribers_url":"https://api.github.com/repos/mila-udem/blocks/subscribers","subscription_url":"https://api.github.com/repos/mila-udem/blocks/subscription","commits_url":"https://api.github.com/repos/mila-udem/blocks/commits{/sha}","git_commits_url":"https://api.github.com/repos/mila-udem/blocks/git/commits{/sha}","comments_url":"https://api.github.com/repos/mila-udem/blocks/comments{/number}","issue_comment_url":"https://api.github.com/repos/mila-udem/blocks/issues/comments{/number}","contents_url":"https://api.github.com/repos/mila-udem/blocks/contents/{+path}","compare_url":"https://api.github.com/repos/mila-udem/blocks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mila-udem/blocks/merges","archive_url":"https://api.github.com/repos/mila-udem/blocks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mila-udem/blocks/downloads","issues_url":"https://api.github.com/repos/mila-udem/blocks/issues{/number}","pulls_url":"https://api.github.com/repos/mila-udem/blocks/pulls{/number}","milestones_url":"https://api.github.com/repos/mila-udem/blocks/milestones{/number}","notifications_url":"https://api.github.com/repos/mila-udem/blocks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mila-udem/blocks/labels{/name}","releases_url":"https://api.github.com/repos/mila-udem/blocks/releases{/id}","created_at":"2014-10-06T00:08:32Z","updated_at":"2015-11-04T16:05:35Z","pushed_at":"2015-11-04T19:50:07Z","git_url":"git://github.com/mila-udem/blocks.git","ssh_url":"git@github.com:mila-udem/blocks.git","clone_url":"https://github.com/mila-udem/blocks.git","svn_url":"https://github.com/mila-udem/blocks","homepage":"","size":30010,"stargazers_count":528,"watchers_count":528,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":152,"mirror_url":null,"open_issues_count":147,"forks":152,"open_issues":147,"watchers":528,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mila-udem/blocks/pulls/899"},"html":{"href":"https://github.com/mila-udem/blocks/pull/899"},"issue":{"href":"https://api.github.com/repos/mila-udem/blocks/issues/899"},"comments":{"href":"https://api.github.com/repos/mila-udem/blocks/issues/899/comments"},"review_comments":{"href":"https://api.github.com/repos/mila-udem/blocks/pulls/899/comments"},"review_comment":{"href":"https://api.github.com/repos/mila-udem/blocks/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mila-udem/blocks/pulls/899/commits"},"statuses":{"href":"https://api.github.com/repos/mila-udem/blocks/statuses/b87ad2eab6d9f106dbde61e0735af1c333cbc5dd"}}}}