一. 含义
- FLOPs(计算量):注意s小写,是floating point operations的缩写(这里的小s则表示复数),表示浮点运算数,理解为计算量。可以用来衡量算法/模型的复杂度。
- FLOPS(计算速度):注意全大写,是floating point operations per second的缩写(这里的大S表示second秒),表示每秒浮点运算次数,理解为计算速度。是一个衡量硬件性能的指标。
- Params(参数量):没有固定的名称,大小写均可,表示模型的参数量,也是用来衡量算法/模型的复杂度。通常我们在论文中见到的是这样:# Params,那个井号是表示 number of 的意思,因此 # Params 的意思就是:参数的数量。
二. 使用thop库计算FLOPs和Params
- 安装
pip install thop
- 使用
使用thop库来计算vgg16模型的计算量和参数量:
import torch
from thop import profile
from archs.ViT_model import get_vit, ViT_Aes
from torchvision.models import