相关疑难解决方法(0)

如何从张量流中的tfprof计算触发器?

我怎样才能获得的数量flopstfprof我的代码如下:

def calculate_flops():
    # Print to stdout an analysis of the number of floating point operations in the
    # model broken down by individual operations.
    param_stats = tf.contrib.tfprof.model_analyzer.print_model_analysis(
    tf.get_default_graph(),
    tfprof_options=tf.contrib.tfprof.model_analyzer.
    TRAINABLE_VARS_PARAMS_STAT_OPTIONS)
    print(param_stats)
Run Code Online (Sandbox Code Playgroud)

但结果说flops = 0。我该如何计算翻牌数。我可以举个例子吗?

tensorflow

5
推荐指数
1
解决办法
1543
查看次数

如何在Keras中计算Mobilenet FLOP

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))
Run Code Online (Sandbox Code Playgroud)

当我运行上面的代码时,我得到了下面的结果

1,137,481,704 --- 4,253,864
Run Code Online (Sandbox Code Playgroud)

这与本文所述的触发器不同。

移动网络:https ://arxiv.org/pdf/1704.04861.pdf

ShuffleNet:https://arxiv.org/pdf/1707.01083.pdf

如何计算论文中所述的确切触发器?

flops deep-learning keras

1
推荐指数
4
解决办法
3951
查看次数

标签 统计

deep-learning ×1

flops ×1

keras ×1

tensorflow ×1