{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/4818","repository_url":"https://api.github.com/repos/fchollet/keras","labels_url":"https://api.github.com/repos/fchollet/keras/issues/4818/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/4818/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/4818/events","html_url":"https://github.com/fchollet/keras/issues/4818","id":197454852,"number":4818,"title":"MaxPooling2d() turns odd input into even numbers, is there anyway to go around this?","user":{"login":"0bserver07","id":2153691,"avatar_url":"https://avatars.githubusercontent.com/u/2153691?v=3","gravatar_id":"","url":"https://api.github.com/users/0bserver07","html_url":"https://github.com/0bserver07","followers_url":"https://api.github.com/users/0bserver07/followers","following_url":"https://api.github.com/users/0bserver07/following{/other_user}","gists_url":"https://api.github.com/users/0bserver07/gists{/gist_id}","starred_url":"https://api.github.com/users/0bserver07/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0bserver07/subscriptions","organizations_url":"https://api.github.com/users/0bserver07/orgs","repos_url":"https://api.github.com/users/0bserver07/repos","events_url":"https://api.github.com/users/0bserver07/events{/privacy}","received_events_url":"https://api.github.com/users/0bserver07/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-24T08:45:23Z","updated_at":"2017-01-01T19:55:56Z","closed_at":null,"body":"During `MaxPooling2d()` the row with odd number `[ 45 ]` becomes even `[ 22 ]`, this becomes an issue during Deconv or let's say `UpSampling2D()`, it doesn't count up to the same sizes as it started.\r\n\r\nHere is a [gist of the full model](https://gist.github.com/0bserver07/502ffd62d4b4df939af03ef66ec1c8de), but what I'm pointing to is the `maxpooling2d_59`\r\n\r\n\r\n```\r\nblock4_conv3 (Convolution2D)     (None, 512, 45, 60)   2359808     activation_299[0][0]             \r\n____________________________________________________________________________________________________\r\nbatchnormalization_312 (BatchNorm(None, 512, 45, 60)   120         block4_conv3[0][0]               \r\n____________________________________________________________________________________________________\r\nactivation_300 (Activation)      (None, 512, 45, 60)   0           batchnormalization_312[0][0]     \r\n____________________________________________________________________________________________________\r\nmaxpooling2d_59 (MaxPooling2D)   (None, 512, 22, 30)   0           activation_300[0][0]             \r\n____________________________________________________________________________________________________\r\nblock5_conv1 (Convolution2D)     (None, 512, 22, 30)   2359808     maxpooling2d_59[0][0]            \r\n____________________________________________________________________________________________________\r\nbatchnormalization_313 (BatchNorm(None, 512, 22, 30)   60          block5_conv1[0][0]               \r\n____________________________________________________________________________________________________\r\nactivation_301 (Activation)      (None, 512, 22, 30)   0           batchnormalization_313[0][0]   \r\n\r\n```\r\n\r\nThe issue is here, at size `22` to `44`, rather `45`\r\n\r\n```\r\n\r\nconvolution2d_42 (Convolution2D) (None, 512, 22, 30)   2359808     activation_305[0][0]             \r\n____________________________________________________________________________________________________\r\nbatchnormalization_318 (BatchNorm(None, 512, 22, 30)   60          convolution2d_42[0][0]           \r\n____________________________________________________________________________________________________\r\nactivation_306 (Activation)      (None, 512, 22, 30)   0           batchnormalization_318[0][0]     \r\n____________________________________________________________________________________________________\r\nupsampling2d_52 (UpSampling2D)   (None, 512, 44, 60)   0           activation_306[0][0]             \r\n____________________________________________________________________________________________________\r\nconvolution2d_43 (Convolution2D) (None, 512, 44, 60)   2359808     upsampling2d_52[0][0]            \r\n____________________________________________________________________________________________________\r\nbatchnormalization_319 (BatchNorm(None, 512, 44, 60)   120         convolution2d_43[0][0]           \r\n____________________________________________________________________________________________________\r\nactivation_307 (Activation)      (None, 512, 44, 60)   0           batchnormalization_319[0][0]     \r\n____________________________________________________________________________________________________\r\n\r\n```\r\n\r\nIt causes this error otherwise continuing to a `Reshape()` .\r\n\r\n```python \r\nValueError: total size of new array must be unchanged\r\n```\r\n\r\nRelevant issues and each seem to solve it a different way: \r\n\r\n1. [ Unpooling and deconvolution #378 ](https://github.com/fchollet/keras/issues/378)\r\n2. [ MaxPooling2D fails to utilize last column in odd dimensional input #2094](https://github.com/fchollet/keras/issues/2094)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/269916974","html_url":"https://github.com/fchollet/keras/issues/4818#issuecomment-269916974","issue_url":"https://api.github.com/repos/fchollet/keras/issues/4818","id":269916974,"user":{"login":"0bserver07","id":2153691,"avatar_url":"https://avatars.githubusercontent.com/u/2153691?v=3","gravatar_id":"","url":"https://api.github.com/users/0bserver07","html_url":"https://github.com/0bserver07","followers_url":"https://api.github.com/users/0bserver07/followers","following_url":"https://api.github.com/users/0bserver07/following{/other_user}","gists_url":"https://api.github.com/users/0bserver07/gists{/gist_id}","starred_url":"https://api.github.com/users/0bserver07/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0bserver07/subscriptions","organizations_url":"https://api.github.com/users/0bserver07/orgs","repos_url":"https://api.github.com/users/0bserver07/repos","events_url":"https://api.github.com/users/0bserver07/events{/privacy}","received_events_url":"https://api.github.com/users/0bserver07/received_events","type":"User","site_admin":false},"created_at":"2017-01-01T19:55:56Z","updated_at":"2017-01-01T19:55:56Z","body":"Thanks a lot for the detailed answer, I'm wondering how would the ZeroPadding effect the model over all.\r\n\r\nI'm essentially implementing the full version of Segnet and in the original paper they don't seem to do either cropping or ZeroPadding, but will definitely try this out.\r\n[SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation](https://arxiv.org/abs/1511.00561)\r\n"}}
{"actor":{"display_login":"0bserver07"}}