延迟加载未在TensorBoard上生成图

时间:2019-09-24 06:44:36

标签: tensorflow tensorboard

我试图以两种方式在张量流中进行操作以了解 正常加载和延迟加载之间的差异。 当我运行正常的加载时,事情按预期进行。下面是代码 正常加载

正常加载

import tensorflow as tf
with tf.Graph().as_default() as my_graph:
  a = tf.constant(10, name='constant_a')
  b = tf.constant(30, name='constant_b')
  c = tf.add(a, b, name='add_a_b_gen_c')

  with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    writer = tf.summary.FileWriter("graph_dir", sess.graph)
    for _ in range(10):
      print(sess.run(c))
    writer.close()
  print(tf.get_default_graph().as_graph_def())

以下是该操作的张量板屏幕截图 enter image description here

但是当我更改代码时,而不是存储tf.add(a,b)的值 在C中,我在运行会话(延迟加载)中调用此方法,那么这不是 在graphboard上生成预期的图形。 请参阅下面更改的代码

延迟加载

import tensorflow as tf
with tf.Graph().as_default() as my_graph:
  a = tf.constant(10, name='constant_a')
  b = tf.constant(30, name='constant_b')

  with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    writer = tf.summary.FileWriter("graph_dir", sess.graph)
    for _ in range(10):
      print(sess.run(tf.add(a, b, name='add_a_b')))
    writer.close()
  print(tf.get_default_graph().as_graph_def())

Tensorboard输出与我预期的不同。它仅显示值init,不显示a和b值。

Screenshot1

this参考中,该图应如下图所示 enter image description here

为了进一步说明,下面的功能是在包含10个节点副本的延迟加载中为该图生成protobuf。

tf.get_default_graph().as_graph_def()

任何人都可以帮助我了解为什么该图形未显示在张量板上吗?

0 个答案:

没有答案