XinnHe / ST-UNet

126 stars 13 forks source link

模型的复杂度 #12

Open long123524 opened 1 year ago

long123524 commented 1 year ago

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

XinnHe commented 1 year ago

你可以试试这个
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 commented 1 year ago

朋友,用这个,亲测可以 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 commented 1 year ago

Flops 68.62G image

long123524 commented 1 year ago

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

XinnHe commented 1 year ago

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

long123524 commented 1 year ago

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

XinnHe commented 1 year ago

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

XinnHe commented 1 year ago

感谢🙇‍

long123524 commented 1 year ago

客气了,互相学习