从github官网上转载的:
Count the MACs / FLOPs of your PyTorch model.
THOP: PyTorch-OpCounter
How to install
pip install thop (now continously intergrated on Github actions)
OR
pip install --upgrade git+https://github.com/Lyken17/pytorch-OpCounter.git
How to use
-
Basic usage
from torchvision.models import resnet50 from thop import profile model = resnet50() input = torch.randn(1, 3, 224, 224) macs, params = profi

本文介绍了如何使用THOP库来计算PyTorch模型的FLOPs和MACs,这两个指标是衡量深度学习模型计算复杂度的关键。通过示例展示了安装和使用THOP的方法,以及如何自定义规则计算第三方模块。此外,文中还提供了多个流行模型的参数和计算量数据,帮助理解不同模型的性能差异。FLOPs等于两倍的MACs,因此THOP得到的MACs需乘以2来获取FLOPs值。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



