Params:
查看整个网络的参数量:
sum(x.numel() for x in model )
查看某一层的参数量:
for m in model:
# name_parameters() 包含层名和参数量
m_p = list(m.parameters())
mp =sum(k.numel() for k in m_p )
print( mp)
FLOPs 通常用GFLOPs来展示
thop.profile(模型,当前模型需要尺度的输入)
查看整个网络的计算量:
flops = thop.profile(deepcopy(model), inputs=[im], verbose=False)[0] / 1E9 * 2 if thop else 0 # stride GFLOPs
查看某一层的计算量:
for m in model:
o = thop.profile(m,input=[c.copy() ],verbose=False)[0] / 1E9 * 2 if thop else 0 # FLOPs