gpt4 book ai didi

Tensorflow "Incomplete shape"是什么意思?

转载 作者:行者123 更新时间:2023-12-03 09:45:52 26 4
gpt4 key购买 nike

我正在查看 tensorflow 日志并发现以下行:

4 ops no flops stats due to incomplete shapes. Consider passing run_meta to use run_time shapes.

此消息似乎来自 following code :

for op in graph.get_operations():
try:
stats = ops.get_stats_for_node_def(
graph, op.node_def, REGISTERED_FLOP_STATS)
except ValueError:
# Catch Exception When shape is incomplete. Skip it.
op_missing_shape += 1
stats = None
......
if op_missing_shape > 0 and not run_meta:
sys.stderr.write('%d ops no flops stats due to incomplete shapes.\n' %
op_missing_shape)

在与 GRU 类似的情况下,日志中不会出现此行。所以我假设错误不是由批量大小引起的。你能解释一下是什么吗?另外我如何添加“run_meta”属性?谢谢。

最佳答案

'...由于不完整的形状而没有翻牌统计'意味着您对某些变量有未知的[形状]信息,例如当您处理可变批量大小([无] 形状)或 tf.while_loop 任意时间等时。

根据官方tfprof文档(source):

  • It must have known "shape" information for RegisterStatistics('flops') to calculate the statistics. It is suggested to pass in -run_meta_path if shape is only known during runtime. tfprof can fill in the missing shape with the runtime shape information from RunMetadata.


至于RunMetadata,有一个 tf.RunMetadata()在 tensorflow 中,这应该是你需要的。通常你将它传递给 sess.run()操作。

对此的解决方案是在运行时传递 RunMetadata,届时将定义所有形状。
# Generate the RunMetadata that contains the memory and timing information.
#
# Note: When run on GPU, a kernel is first scheduled (enqueued) and then
# executed asynchronously. tfprof only tracks the execution time.
#
run_metadata = tf.RunMetadata()
with tf.Session() as sess:
_ = sess.run(train_op,
options=tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE),
run_metadata=run_metadata)

希望这可以帮助。

关于Tensorflow "Incomplete shape"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44555496/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com