pytorch之網絡參數統計 torchstat & torchsummary


參考 :

https://blog.csdn.net/weixin_45292794/article/details/108227437

 

https://blog.csdn.net/jzwong/article/details/110954725

 

 

 

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

 

 

 

 

兩個pytorch的網絡參數統計工具:

 

 

1.  torchstat

pip install torchstat

 

 

 

 

2.  torchsummary

兩種安裝方式,測試發現均可使用:

pip install torchsummary

pip install torch-summary

 

 

 

 

 

 

 

 

 

 

 

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

 

 

 

 

 

使用方式:

1.  torchstat

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

 

 

 

 

 

 

 

 

 

 

 

 

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

 

那么打印結果沒有層次感:

 

 

 

 

 

 

如果安裝方式:

pip install torch-summary

 

那么打印結果有層次感:

 

 

 

 

 

 

使用起來還是   pip install torch-summary  顯示結果簡潔清爽,不過功能強大上還是  pip install torchstat   更勝一籌。

 

 

 

 

建議配合使用:

torch-summary只能看到網絡結構和參數數量:

 

 

 

 

 

 

 

torchstat 可以看到更多的信息,如參數的內存大小:

 

 

 

 

 關於計算指標:

FLOPS、MAdds、MACC指標:

 https://blog.csdn.net/sunlanchang/article/details/103666342

 

 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM