FLOPs如何计算

参考:

  • https://www.zhihu.com/question/65305385/answer/451060549
  • https://www.zhihu.com/question/65305385/answer/642367100
  • PRUNING CONVOLUTIONAL NEURAL NETWORKS FOR RESOURCE EFFICIENT INFERENCE, ICLR2017

1.FLOPs的定义

    要注意区分FLOPs和FLOPS
  • FLOPs:s小写,是floating point operations的缩写(s表复数),指浮点运算数,即计算量,可用来衡量模型复杂度。
  • FLOPS:全大写,是floating point operations per second的缩写,意指每秒浮点运算次数,理解为计算速度,用来衡量硬件性能。

2.简单的计算方式

以下均不考虑activation function。

2.1.卷积层


Ci=input channel, k=kernel size, HW=output feature map size, Co=output channel.
2是因为一个MAC算2个operations。不考虑bias时有-1,有bias时没有-1。
上面针对一个input feature map,没考虑batch size。

2.2.全联接层


I=input neuron numbers, O=output neuron numbers,2是因为一个MAC算2个operations。不考虑bias时有-1,有bias时没有-1。

2.3.反卷积

你可能感兴趣的:(FLOPs如何计算)