Gauss
Gauss

Reputation: 499

About tensorflow Metadata and RunOptions

When I use tensorboard, I find the code:

run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()

But I can't understand the meaning of this code, I have tried to search the explanation, but failed. Can anyone provide me some detailed materials or explain to me about the metadata and runoptions? What is the purpose of metadata and runoptions?

Upvotes: 13

Views: 7606

Answers (2)

Salvador Dali
Salvador Dali

Reputation: 222811

These options are needed to extract runtime statistics of the graph execution. It adds information about the time of execution and memory consumption to your event files and allow you to see this information in tensorboard.

Basically you define these options and then pass them to sess.run and write them to writer:

run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
sess.run(<values_you_want_to_execute>, options=run_options, run_metadata=run_metadata)
your_writer.add_run_metadata(run_metadata, 'step%d' % i)

For more details, read this official guide

Upvotes: 5

Michael Kong
Michael Kong

Reputation: 73

1) trace each iteration, e.g. tensorboard > graphs > session runs; 2) metadata also stores information like run times, memory consumption, e.g.

trace_file = open('/home/mk/Documents/timeline.ctf.json', 'w');
trace = timeline.Timeline(step_stats=run_metadata.step_stats);
trace_file.write(trace.generate_chrome_trace_format());

Upvotes: 6

Related Questions