-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
padding calculation #603
Comments
Can you please be more specific to which component your are referring to? |
Sorry. It is for CMSIS- NN. I am not sure on how to add label |
Base on my understanding, this is what you need to calculate the padding. O = (W−F+2P)/S+1
However, the most important point is this part In your example, To investigate further, there are 4 different paddings instead of 1 number. They are left, right, up, and bottom. Which you can set differently if you do the padding manually. In your example, if we need to ceil on width in you example (to make 29->30), we cannot add padding to right and left evenly because we can only add 1 column to the left or right. So it is now the backend's choice to add it to the left border or right border. A screenshot from Keras shows the differences in each backend |
Thanks Majianjia. |
You dont need to do anything, just floor the padding value from the above equation and pass to CMSIS-NN. In your example, pass 0 for both width and height. Its nn lib's decision to choose to pad left or right. CMSIS-NN pads right same as Tensorflow if I am correct. |
Maianjia,I did that initallly but there was an accuracy drop more than i excepted in the microcontroller , then i was not sure if the drop was due to quantization or if i was giving wrong padding parameter. So to make sure i made the kernel 3 if input dimensions are odd and training the network again and hopefully when i port to cmsis nn it would get better results. |
From my experience, it is probably not the padding's fault. I don't think a minor difference on the border will affect the result much unless it changes the shape of your output data. If quantization failed (especially overflowing), the result will be significantly worse however the model won't completely fail (such as 90% -> 60% not 90%->10%). If you see this symptom, it could be your quantization process's defect. |
Yes, I will check the quantization process next. |
@anathema43 , @majianjia .. There are some new documentation that you might find interesting.. https://developer.arm.com/solutions/machine-learning-on-arm/developer-material/how-to-guides/converting-a-neural-network-for-arm-cortex-m-with-cmsis-nn/single-page |
@felix-johnny |
I had questions regarding padding .calculation of padding in pooling function
if my input dim =(29,45,8) (h,w,c) and output is(15,23,8) with stride =2 and kernel =2, what should be my padding value ?
The text was updated successfully, but these errors were encountered: