tenorflow 模型調優

# Create the Timeline object, and write it to a json
from tensorflow.python.client import timeline
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with tf.gfile.GFile("timeline.json", 'w') as f:
    f.write(ctf)

chrome://tracing/python

from tensorflow.python.profiler import model_analyzer
from tensorflow.python.profiler import option_builder

run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
profiler = model_analyzer.Profiler(graph=self._graph)

for loop in range(1):
    outputs = self._session.run([out], feed_dict=feed_dict,options=run_options, run_metadata=run_metadata)
    profiler.add_step(step=loop, run_meta=run_metadata)

profiler.add_step(step=0, run_meta=run_metadata)
profile_op_opt_builder = option_builder.ProfileOptionBuilder()
profile_op_opt_builder.select(['micros','occurrence'])
profile_op_opt_builder.order_by('micros')
profile_op_opt_builder.with_max_depth(50)
profiler.profile_operations(profile_op_opt_builder.build())
相關文章
相關標籤/搜索