Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 620
Gauss Avatar asked Apr 11 '17 08:04

Gauss


2 Answers

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

like image 122
Salvador Dali Avatar answered Oct 19 '22 02:10

Salvador Dali


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());
like image 39
Michael Kong Avatar answered Oct 19 '22 04:10

Michael Kong