0
点赞
收藏
分享

微信扫一扫

pytorch之网络参数统计 torchstat & torchsummary




两个pytorch的网络参数统计工具:



1.  torchstat

pip install torchstat





2.  torchsummary

两种安装方式,测试发现均可使用:

pip install torchsummary

pip install torch-summary


pytorch之网络参数统计 torchstat & torchsummary_统计工具




pytorch之网络参数统计 torchstat & torchsummary_杂谈_02








===============================================






使用方式:

1.  torchstat

from torchstat import stat
import torchvision.models as models
model = models.resnet152()
stat(model, (3, 224, 224))



pytorch之网络参数统计 torchstat & torchsummary_javascript_03











2.  torchsummary

import torchvision.models as models
from torchsummary import summary

model = models.resnet152()
summary(model.cuda(),input_size=(3,32,32),batch_size=-1)


如果安装方式:

pip install torchsummary


那么打印结果没有层次感:

pytorch之网络参数统计 torchstat & torchsummary_杂谈_04







如果安装方式:

pip install torch-summary


那么打印结果有层次感:

pytorch之网络参数统计 torchstat & torchsummary_统计工具_05







使用起来还是   pip install torch-summary  显示结果简洁清爽,不过功能强大上还是  pip install torchstat   更胜一筹。





建议配合使用:

torch-summary只能看到网络结构和参数数量:

pytorch之网络参数统计 torchstat & torchsummary_javascript_06








torchstat 可以看到更多的信息,如参数的内存大小:

pytorch之网络参数统计 torchstat & torchsummary_杂谈_07





 关于计算指标:

FLOPS、MAdds、MACC指标:


举报

相关推荐

0 条评论