I always see that the width and height of the kernel are the same. But is it a good idea to use different numbers?

Recently I tried to use GoogLeNet (which expects images to be 224x224) on my images (500x150) and I got an error:

Negative dimension size caused by subtracting 7 from 5 for 'average_pooling2d_5/AvgPool'...

I know that this error is because the height of my image is too small. If I use the height of about 200, then everything is ok. So, maybe, in this situation, I could just use a smaller height and bigger width in the kernel. For example (5, 3).

Is it a good idea in this case? Or in general? How can it affect the accuracy of the network and the ability to extract different features?


It depends on your application. In case of text recognition, non-uniform kernels are used since the information about text is less on the horizontal axis and more on the vertical axis.

If in your case it is applicable then, it will be good idea. But, if it is not you are better off using a smaller uniform kernel (2x2, maybe). You can also zero-pad your image to make it uniform before putting it through convolutions. Also, check if you are doing 'valid' or 'same' padding in your convolutions since 'valid' convolutions chip away at your image dimensions.

  • $\begingroup$ My task is to create an autonomous car (a bot that play car game). And I use Googlenet which is designed very well so probably changing parameters like kernel size is not a good idea. So it looks like the best solution is to zero pad the image $\endgroup$ – Kacper777 Feb 18 at 21:54
  • $\begingroup$ Yes, that would be the best option for you then. Also, accept the answer. Much thanks. $\endgroup$ – Abhishek Verma Feb 18 at 21:56
  • $\begingroup$ interesting, depends on the task to be done such as non-square objects in image $\endgroup$ – datdinhquoc Feb 19 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.