【问题标题】:How to write graph to tensorboard using tensorflow 2.0?如何使用 tensorflow 2.0 将图形写入 tensorboard?
【发布时间】:2019-07-15 09:00:07
【问题描述】:
正在做这个
# 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()
个人资料部分显示在张量板上,但还没有图表。
【问题讨论】:
标签:
tensorflow
tensorboard
tensorflow2.0
【解决方案1】:
请在 github gist here 中找到我使用 Tf2.0 创建的图表并在 tensorboard 中将其可视化。也可以通过以下link了解更多信息。
下面提到了相同的代码:
!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
如果回答有帮助,请点赞。谢谢!