根据documentation,tf.data.Datasets
在图形模式下工作(在eager和graph模式下):
Note that irrespective of the context in which map_func is defined (eager vs. graph), tf.data traces the function and executes it as a graph
在TensorFlow1.X中,我们可以很容易地在Tensorboard中绘制这个图:处理函数被绘制在一个子图中。你知道吗
例如
def _parse_function(x):
return x * 2
x = tf.constant([0 , 1])
dataset = tf.data.Dataset.from_tensor_slices(x)
dataset = dataset.map(_parse_function)
在Tensorboard中,会出现一个子图,对应于\u parse \u函数:
但是,在Tensorflow 2.0中,这不会在Tensorboard图中生成任何可见元素。 以下代码不会根据Tensorboard生成任何图形:
def _parse_function(x):
return x * 2
logdir = 'logs'
writer = tf.summary.create_file_writer(logdir)
tf.summary.trace_on(graph=True, profiler=True)
x = tf.constant([0 , 1])
dataset = tf.data.Dataset.from_tensor_slices(x)
dataset = dataset.map(_parse_function)
with writer.as_default():
tf.summary.trace_export(
name="trace",
step=0,
profiler_outdir=logdir)
那么,既然一个图是在调用map
时创建的,那么有没有方法访问/可视化这个图呢?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐