-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect ZeroPadding before MaxPool2D in keras' resnet #48105
Comments
Hey! here's a solution I think that can be implemented . |
Here's a pr in eras repo as i am unable to find keras/application on the tensorflow repo . -:Update resnet.py #1 |
In the PR-I've changed the pool1_pad layer's padding to (1, 0) for the right and bottom edges. This will ensure that the padding is added only on the top and left sides, which compensates for the even-sized input. |
I can't find the pr you're referring to. In any case, if I understood you correctly, removing the right and bottom padding would only avoid wasteful addition of elements that won't be used. The main issue was that a value of zero is not correct for padding the input of a maxpool layer with signed type. It should be padded with the minimum representable value of the type or just use same padding and avoid the pad layer if supported. |
Hi, the source for the keras code is now github.com/keras-team/keras and soon github.com/keras-team/keras-core. Actually Either way, if this issue still exists, please re-raise it on the Keras repo(s). |
Hi,
I've noticed that the implementation of resnet networks in keras introduces a ZeroPadding layer before the initial MaxPool2D 3x3 stride 2:
tensorflow/tensorflow/python/keras/applications/resnet.py
Line 161 in 2040824
I don't think this is correct. Zero is not a neutral element for a MaxPool2D operation. The input values at the edges could be negative.
I believe the intention of that zero padding layer is what would be correctly represented as SAME padding for the MaxPool2D directly. Note that the padding layer is also adding padding elements to the right and bottom edges of the input that the 3x3 stride 2 MaxPool2D operation won't ever use if the input is even size as I believe it commonly is.
The text was updated successfully, but these errors were encountered: