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
FLOPs count seems to be off #17
Comments
Hi Matthew, |
Resnet50: 4GFLOPs Resnet50 is 6 times more flops than the EfficientNetB1 here. EfficientNetB0: 4.1MFLOPs, Paper reported: 3.9MFLOPs Hope it helps. |
@sdoria Actually i think one of the reason why EfficientNetB1 is slower than ResNet50, could be the control flow logic in Padding, deciding whether to pad. |
I assume you are talking about the logic behind 'same' padding in Conv2dSamePadding. I don't think that's a problem. I have an alternative version that sets padding = kernel_size//2 instead and it trains at the same speed (time per epoch) |
My FLOPS calculation code, http://studyai.com/article/a718990b It is more close to paper than your method, but still different. |
For some paper, the "multiply_adds==True", Under "multiply_adds==False", the results are below, which are the same to paper. #model depth param GFLOPs effb0 82l 5.28M 0.393Geffb1 116L 7.79M 0.697Geffb2 116L 9.11M 1.007Geffb3 131L 12.23M 1.851Geffb4 161L 19.34M 4.443G |
@zhjpqq thank you for you info :) |
@zhjpqq hello, I run your code but the results is different from yours:
*** Number of params: 5.288548 million... |
@zhjpqq Could you share the code you used to receive those results here? I am not able to enter site from the link you have sent. EDIT_0: EDIT_1:
EDIT_2:
I think I fixed it in this pull request: #223 I am also using different flop_count method that I recommend |
Hi, |
@shen494157765 Use this one: https://github.com/facebookresearch/fvcore/blob/ffd5dfff8ee6d5a88939376f208b08022562e789/fvcore/nn/flop_count.py#L28 it should work just fine. |
Hi, Yes, I used the package of fvcore, and my code is below:
but the result is Skipped operation aten::batch_norm 69 time(s) which is different from the result in paper. (efficientnet b2) Thanks |
There is ongoing work on pytorch side. There are multiple packages to calculate flops but this one is the closest to original I was able to find. Other packages you can try: |
Hi, Thanks for your reply, I have tried that 'ongoing' work, and I got the results which were similar to the results I got from the tool 'fvcore' (https://github.com/facebookresearch/fvcore/blob/master/fvcore/nn/flop_count.py) And now I just think that the only way to calculate the flops of this efficientnet is calculating by myself..... Thanks |
Also @shen494157765 please make sure you are using the newest verion of this library. I have proposed fix (#223) to the architecture lately. |
Hi, Yes, I have used the latest version when I calculated the flops. The result is that the efficientnet b0 has 0.821842112 GFLOPs (about 0.41 GMACs), which is similar to 0.39 showed in paper. (Just ignore the GFLOPs GMACs, I just think that the result in paper is GMACs not GFLOPs, buy anyway, many papers has same kind of definition.) But for other kinds of efficientnet (b1 - b7), there are too much layers for them, so I did not choose them to verify the result. For my own experiments, what I need is part of layers in efficientnet, and that is the reason that I need to know how to calculate the flops of efficientnet. Now, I just calculated it manually with every conv2d. If you know there is some tool that can get a similar result to the efficientnet paper, please let me know. I do not know that if you have tried the tool you recommended above (can get the closet result) in effcientnet b6 or b7, that was a real disaster. Thanks |
@matthewygf I think your input size maybe (3,224,224) for all models(efficientnet-b0,efficientnet-b1,..etc.),but the input size of paper is variable for different models |
Hi Luke, Thanks for your great work !
I am interested in the FLOPs of the models implemented.
I have always been using this to count FLOPs.
And for most cases, models from vision:
they all seems to match the FLOPs count from paper.
However in this case it is not. I can not think of a reason why, when i traverse the code down to each module, even added the FLOPs count for both padding inside the conv2dblock and Swish activation .
Do you have any idea?
Thanks in advance.
The text was updated successfully, but these errors were encountered: