详细计算:卷积神经网络CNN中的参数量(parameters)和计算量(FLOPs ) - 知乎
FLOPS: 全大写,指每秒浮点运算次数,可以理解为计算的速度。是衡量硬件性能的一个指标。(硬件)
FLOPs: s小写,指浮点运算数,理解为计算量。可以用来衡量算法/模型的复杂度。(模型) 在论文中常用GFLOPs(1 GFLOPs = 10^9 FLOPs)
安装方式:
pip install torchstat
使用方法:
from torchstat import stat
import torchvision.models as models
model = models.alexnet()
stat(model, (3, 224, 224))
用来计算pytorch构建的网络的参数,空间大小,MAdd,FLOPs等指标;
使用torchsummary 计算参数:
pip install torchsummary
import torch
import torchvision.models as models
model = models.alexnet()
from torchsummary import summary
summary(model, (3, 224, 224))
工具:fvcore/docs/flop_count.md at main · facebookresearch/fvcore · GitHub