-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Changing to AdaptiveAvgPool2d on Alexnet #746
Conversation
The update allows Alexnet to process images larger or smaller than prescribed imagenet size using adaptive average pooling. Will be useful while finetuning or testing on different resolution images. Similar to #643 and #672. I did not include adaptive avg pool in features or classifier block so that these predefined blocks can be used as it is.
Doesn't this change the accuracy? |
I believe the output should be the same if the images have the same size as before (224x224). @ekagra-ranjan can you double-check? |
Yes @fmassa, it won't change if we pass the original input dimension on which the net was trained. This is because AdaptiveAvgPool will receive a Cx6x6 input (if you pass the precribed imagnet size by AlexNet) and so the output will be equal to the input as AdaptiveAvgPool has output dim as Cx6x6 also, making the predictions unchanged. If you pass larger sized images then it might be different compared to the original input size for the same task but that won't matter as your aim is to train the net on your larger resolution for whatever reason like maybe improving the performance by passing higher resolution images. |
@TheCodez if your confusion was due to my description that the modification could handle smaller input dimensions then sorry for that. I have made the correction in my description. |
@ekagra-ranjan thanks for the explanation 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
And for inputs smaller than 224? I'm working with 80x80 images, and I'm not sure if I should process these images to fit the network or to manually change the input that is expected by the network. Also, if I change the input, I must change the filter's parameters so every layer has a correct output size, right? Thank you |
@franciscocms in this case, I would say you should resize the images to be 224x224. If you still want to use 80x80, you'll need to change the network structure to fit your data, but it won't be the exact same model anymore. |
@fmassa thank you for your answer! What type of resizing would you consider? Like padding with reflection in order to achieve the 224x224(or close to that) image? I've made some calculations and saw that if I used the 80x80 input, the output of the convolutional part will be 2x2x256, which I think is really small, and some information per filter might get lost. |
@franciscocms You can try those out things. IMO, interpolating the 80x80 images to 224x224 could work better. |
Ok, I'll try it out! Thank you! |
The update allows Alexnet to process images larger than prescribed imagenet size using adaptive average pooling. Will be useful while finetuning or testing on different resolution images. Similar to #643 and #672. I did not include adaptive avg pool in features or classifier block so that these predefined blocks can be used as it is.