-
Notifications
You must be signed in to change notification settings - Fork 520
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
calculation of AvgPooling #55
Comments
I think you suggestion is correct. In total there are H_out * W_out * out_channels pixels and each pixel takes ** in_channels * (kernel_size * kernel_size - 1) ** operations. For MACs and FLOPs, it is not simple 2 times calculation. In short, it depends how you count the multiplication for floating numbers. I will refactor the codebase to fix the issue. |
Thank you! Will you please let me know as soon as you fixed the code, so that I can update the python package? |
After talking to an expert in hardware, I made a clarification of MACs and FLOPs. For AVGPooling, the updated MAC should be H_out * W_out * out_channels. If you agree with it, I will update the corresponding code recently. |
@fortunex3000 any comments? |
But if you do this, it is different from the statistical method of TensorFlow and the user’s conventional perception |
Could you please give a closer explanation for the calculation of the AvgPool FLOPs? Despite I know that the impact of pooling layers is minimal, I'd like to understand the calculation. As I get from the code the formular for 2dAvgPooling you use is: (kernel_size + 1) * H_out * W_out * in_channels * out_channels
But if I consider the formular on the pytorch website I'd calculate them as follows:
For each kernel beeing applied on your input you have kernel_size * kernel_size - 1 additions plus one division plus one multiplication of your kernel_size inside the denominator. You apply out_channels kernels on in_channels input channels which result in a H_out * W_out output. This is the computation for all multiplications and additions. To be compliant with the regular understanding of MACs and FLOPs you devide by 2 as two MACs result in one FLOP. So finally I get the formular: FLOPs = (kernel_size * kernel_size - 1) * H_out * W_out * in_channels * out_channels / 2
The text was updated successfully, but these errors were encountered: