Skip to content
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

模型的复杂度 #12

Open
long123524 opened this issue Jan 31, 2023 · 9 comments
Open

模型的复杂度 #12

long123524 opened this issue Jan 31, 2023 · 9 comments

Comments

@long123524
Copy link

您好,我想知道ST-UNet的GFLOPs是多少呢?我始终没有计算出来结果,因为我想要和它做比较,如果您能告诉我,我将不胜感激。

@XinnHe
Copy link
Owner

XinnHe commented Feb 14, 2023

你可以试试这个
from thop import profile
input = torch.randn(1, 3, 256,256).cuda() # 11, 512, 512
flops, params = profile(model, inputs=(input,))
print('FLOPs = ' + str(flops / 1024 ** 3) + 'G')
print('Params = ' + str(params / 1024 ** 2) + 'M')
print('---------------------------------------------------------------')

@XinnHe
Copy link
Owner

XinnHe commented Feb 17, 2023

朋友,用这个,亲测可以
from torchstat import stat
input_size=(3,256,256)
stat(model,(3,256,256))

把报错的地方改成assert len(inp.size()) >= 2 and len(out.size()) >= 2
参考的是这个博客:https://blog.csdn.net/qq_41990294/article/details/128888467

@XinnHe
Copy link
Owner

XinnHe commented Feb 17, 2023

Flops 68.62G
image

@long123524
Copy link
Author

long123524 commented Feb 17, 2023

谢谢,但我发现state库算的不准(有些算不出来),我使用的这个from torchinfo import summary
print(summary(net, input_size=(8, 3, 256, 256))) 统计参数量和GFLOPs

@XinnHe
Copy link
Owner

XinnHe commented Feb 17, 2023

我试了summary,summary测不出来GFLOPs
image

@long123524
Copy link
Author

image
应该是这个78.69G。但是我算的是
image
我输入形状是(8,3,256,256)

@XinnHe
Copy link
Owner

XinnHe commented Feb 17, 2023

哦哦哦,我计算的是(1,3,512,512)

@XinnHe
Copy link
Owner

XinnHe commented Feb 17, 2023

感谢🙇‍

@long123524
Copy link
Author

客气了,互相学习

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants