我正在做这个
# eager on
tf.summary.trace_on(graph=True, profiler=True)
tf.summary.trace_export('stuff', step=1, profiler_outdir='output')
# ... call train operation
tf.summary.trace_off()
配置文件部分显示在张量板上,但还没有图表。
请找到 github gisthere https://colab.research.google.com/gist/gowthamkpr/75b703fec1b89c02b4b7644b29d2b797/untitled100.ipynb我使用 Tf2.0 创建了一个图,并在张量板上将其可视化。另外,想要了解更多信息,请浏览以下内容link https://www.tensorflow.org/tensorboard/r2/graphs.
下面提到了相同的代码:
!pip install tensorflow==2.0.0-beta1
import tensorflow as tf
# The function to be traced.
@tf.function
def my_func(x, y):
# A simple hand-rolled layer.
return tf.nn.relu(tf.matmul(x, y))
# Set up logging.
logdir = './logs/func'
writer = tf.summary.create_file_writer(logdir)
# Sample data for your function.
x = tf.random.uniform((3, 3))
y = tf.random.uniform((3, 3))
# Bracket the function call with
# tf.summary.trace_on() and tf.summary.trace_export().
tf.summary.trace_on(graph=True, profiler=True)
# Call only one tf.function when tracing.
z = my_func(x, y)
with writer.as_default():
tf.summary.trace_export(
name="my_func_trace",
step=0,
profiler_outdir=logdir)
%load_ext tensorboard
%tensorboard --logdir ./logs/func
如果回答有帮助,请点赞。谢谢!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)