急切模式下的RunMetadata

问题描述 投票:0回答:1

急切模式是否支持r1.8中的tf.profiler?由于它不再具有会话对象,有没有办法将tf.RunMetadata()传递给执行?我看到探查器构造函数检查了急切模式;但没有RunMetadata它不起作用。谢谢!

tensorflow
1个回答
-2
投票
with context.eager_mode():
  outfile = os.path.join(test.get_temp_dir(), 'dump')
  opts = builder(
      builder.time_and_memory()).with_file_output(outfile).build()

  context.enable_run_metadata()

  # run your model here #

  profiler = model_analyzer.Profiler()
  profiler.add_step(0, context.export_run_metadata())
  context.disable_run_metadata()
  profiler.profile_operations(opts)

您可以参考以下链接(testEager函数)。 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/profiler/model_analyzer_test.py

© www.soinside.com 2019 - 2024. All rights reserved.