- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
run_meta = tf.RunMetadata()
enter codwith tf.Session(graph=tf.Graph()) as sess:
K.set_session(sess)
with tf.device('/cpu:0'):
base_model = MobileNet(alpha=1, weights=None, input_tensor=tf.placeholder('float32', shape=(1,224,224,3)))
opts = tf.profiler.ProfileOptionBuilder.float_operation()
flops = tf.profiler.profile(sess.graph, run_meta=run_meta, cmd='op', options=opts)
opts = tf.profiler.ProfileOptionBuilder.trainable_variables_parameter()
params = tf.profiler.profile(sess.graph, run_meta=run_meta, cmd='op', options=opts)
print("{:,} --- {:,}".format(flops.total_float_ops, params.total_parameters))
1,137,481,704 --- 4,253,864
最佳答案
tl;博士 你真的得到了正确的答案!您只是将触发器与乘法累加(来自论文)进行比较,因此需要除以二。
如果您使用的是 Keras,那么您列出的代码有点过于复杂了……
让 model
是任何编译的 Keras 模型。我们可以使用以下代码得出模型的失败点。
import tensorflow as tf
import keras.backend as K
def get_flops():
run_meta = tf.RunMetadata()
opts = tf.profiler.ProfileOptionBuilder.float_operation()
# We use the Keras session graph in the call to the profiler.
flops = tf.profiler.profile(graph=K.get_session().graph,
run_meta=run_meta, cmd='op', options=opts)
return flops.total_float_ops # Prints the "flops" of the model.
# .... Define your model here ....
# You need to have compiled your model before calling this.
print(get_flops())
但是,当我查看自己在计算机上所做的示例(不是 Mobilenet)时,打印出来的
total_float_ops 是 2115 当我简单地打印
flops
时,我得到了以下结果多变的:
[...]
Mul 1.06k float_ops (100.00%, 49.98%)
Add 1.06k float_ops (50.02%, 49.93%)
Sub 2 float_ops (0.09%, 0.09%)
很明显
total_float_ops
属性考虑乘法、加法和减法。
flops
的一半结果你有。因此,您有正确的答案,只是您将翻牌误认为是乘法加法(又名乘法累加或 MAC)。
关于deep-learning - 如何在 Keras 中计算 Mobilenet FLOPs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49525776/
我来自这个线程:FLOPS Intel core and testing it with C (innerproduct) 当我开始编写简单的测试脚本时,我想到了几个问题。 为什么是 float ?我
我如何测量 FLOPS或 IOPS ?如果我测量普通浮点加法/乘法的时间,它是否等同于 FLOPS? 最佳答案 FLOPS 是每秒的浮点运算。要测量 FLOPS,您首先需要执行此类操作的代码。如果你有
我的系统: 系统规范:Intel core2duo E4500 3700g内存二级缓存2M x64 fedora 17 我如何测量 flops/mflops 好吧,我使用 papi 库(读取硬件性能计
我正在对一个 GPU(无法透露是哪个)进行建模以估计 OpenCL 和 OpenGL 应用程序的性能,该模型可以合理地估计正在执行的应用程序/内核/代码的 FLOPS 有没有办法从FLOPS,还是对帧
我想知道 Tensorflow 卷积层中浮点运算的数量。 当我等待这个功能在 TF 2.x 上发布时,我在 TF 1.x 上进行了尝试,结果我不明白它是如何计算的,其中之一非常糟糕令人印象深刻(检查第
为了测量 CPU 的峰值 FLOPS 性能,我编写了一个小的 C++ 程序。但是测量结果给我的结果比我的 CPU 的理论峰值 FLOPS 大。怎么了? 这是我写的代码: #include #incl
我想知道快速傅里叶变换 (FFT) 执行了多少 FLOPS。 所以,如果我有一个 1 维数组,包含 N 个 float ,我想计算这组数字的 FFT,有多少 FLOPS 需要执行吗? 我知道这取决于所
数学库经常根据 FLOPS 进行比较。当我看到 FLOPS 与大小的关系图以及几个不同数学库的点集时,向我传达了什么信息? 如果比较相同算法的两个实现或两个不同硬件上的相同软件,FLOPS 作为性能衡
如何计算应用程序的 FLOPS?如果我有执行指令的总数,我可以将它除以执行时间。但是,如何统计执行的指令数呢? 我的问题很笼统,非常感谢任何语言的回答。但我希望为我的应用程序找到一个由 C/C++ 和
我想计算 LeNet-5 ( paper) 的每一层需要多少触发器。一些论文总共给出了其他架构的 FLOPs(1,2,3)但是,这些论文没有详细说明如何计算 FLOPs 的数量,我不知道有多少 FLO
我能得到的最接近的例子是在这个问题中找到的:https://github.com/tensorflow/tensorflow/issues/899 使用这个最小的可重现代码: import tenso
我想计算图形硬件的理论峰值性能。嗯,其实我想了解一下计算。 以 AMD Radeon HD 6670 为例:AMD Accelerated Parallel Processing Programmin
我被要求测量一个在多 CPU 系统上求解微分方程的 Fortran 程序的性能。我的雇主坚持要求我测量 FLOP/s(每秒 float 操作)并将结果与基准进行比较( LINPACK ),但我不相
Microsoft's Parallel Programming whitepaper描述了在各种 FLOPS 阈值下最优的情况,并且 FLOPS 率是关于何时应使用特定实现的决策点。 如何测量应用程
我被要求测量一个在多 CPU 系统上求解微分方程的 Fortran 程序的性能。我的雇主坚持要求我测量 FLOP/s(每秒 float 操作)并将结果与基准进行比较( LINPACK ),但我不相
我一直在关注 OpenCL 的一些教程,很多时候人们用 FLOPS 来说话.维基百科确实解释了公式,但没有说明它的实际含义?例如,1光年= 9.4605284 × 10^15米,其实就是光在一年中行进
我的问题是我得到了一个长度为 l 的数组。 假设这是我的数组:[1,5,4,2,9,3,6] 我们称它为 A。 这个数组可以有多个子数组,子数组的节点彼此相邻。所以我们可以有 [1,5,4] 或 [2
我们必须实现一个 ASM 程序来乘以坐标方案格式 (COOS) 以及压缩行格式 (CSR) 的稀疏矩阵。现在我们已经实现了所有这些算法,我们想知道与通常的矩阵乘法相比,它们的性能要高多少。我们已经实现
我想编写一个 go 程序来对我的 CPU 进行基准测试并计算出我的笔记本电脑的 GFLOPS。 func benchmarkFlopTime(){ num_operations := int(
如何在现代 x86-64 Intel CPU 上实现每周期 4 次浮点运算( double )的理论峰值性能? 据我了解,SSE 需要三个周期add mul 的五个周期在大多数现代 Intel CPU
我是一名优秀的程序员,十分优秀!