Tensorflow 不理解张力板的输出

Tensorflow 不理解张力板的输出,tensorflow,tensorboard,Tensorflow,Tensorboard,我正在读《山姆·亚伯拉罕》tensorflow的书。在阅读时,我得到了以下代码: import tensorflow as tf with tf.name_scope("Scope_A"): a = tf.add(1, 2, name="A_add") b = tf.multiply(a, 3, name="A_mul") with tf.name_scope("Scope_B"): c = tf.add(4, 5, name="B_add") d = tf.

我正在读《山姆·亚伯拉罕》tensorflow的书。在阅读时,我得到了以下代码:

import tensorflow as tf

with tf.name_scope("Scope_A"):
    a = tf.add(1, 2, name="A_add")
    b = tf.multiply(a, 3, name="A_mul")

with tf.name_scope("Scope_B"):
    c = tf.add(4, 5, name="B_add")
    d = tf.multiply(c, 6, name="B_mul")

e = tf.add(b, d, name="output")

writer = tf.summary.FileWriter('./name_scope_1', graph=tf.get_default_graph())
writer.close()
with tf.name_scope("Scope_B"):
        c = tf.add(4, 5, name="B_add")
        d = tf.multiply(c, 6, name="B_mul")
作为名称范围的示例。当我把它装到张力板上时,我得到了下图

图1:我生成的图。 但可悲的是,这本书提出了一个不同的形象

图2:书中给定的图 我知道这本书很老了,现在不是所有的东西都是一样的。但是从代码和图1来看有些东西看起来可疑

with tf.name_scope("Scope_A"):
        a = tf.add(1, 2, name="A_add")
        b = tf.multiply(a, 3, name="A_mul")
对于给定的“SCOPE_A”,蓝色框是可以的,因为有加法和乘法操作

但是对于下面的代码

import tensorflow as tf

with tf.name_scope("Scope_A"):
    a = tf.add(1, 2, name="A_add")
    b = tf.multiply(a, 3, name="A_mul")

with tf.name_scope("Scope_B"):
    c = tf.add(4, 5, name="B_add")
    d = tf.multiply(c, 6, name="B_mul")

e = tf.add(b, d, name="output")

writer = tf.summary.FileWriter('./name_scope_1', graph=tf.get_default_graph())
writer.close()
with tf.name_scope("Scope_B"):
        c = tf.add(4, 5, name="B_add")
        d = tf.multiply(c, 6, name="B_mul")
没有定义乘法运算

在右侧,有一些辅助节点。从作用域A到[0-15],从作用域B到[0-15]。它们是什么

最后是最重要的问题

如何生成更清晰的图形,如图2中生成的author。

tf.reset_default_graph()
*UPD和建议:

1。如果使用默认图形,请不要忘记重置图形。

tf.reset_default_graph()

2。尝试使用已定义的图形。这是避免这种情况的最安全的选择。

您显示的图形似乎不是该片段的图形;正如你所怀疑的,正确的图表就是书中的那个。确保在运行代码之前清除了日志目录,并且在此之前或之后没有运行任何内容(例如,只需打开一个解释器,运行代码并关闭它)。

我刚刚运行了代码,结果与我在您的书中看到的结果相同(这是我所期望的)。我看到还有一些“SCOPE_A_1”,等等。1)你确定你没有运行代码之外的任何东西吗?(也就是说,您只需打开Python/IPython解释器,运行它并关闭它)?2) 您确定目标目录中没有以前运行的其他日志数据吗?@jdehesa:谢谢您的确认。你是对的。我创建了一个新文件夹,再次运行相同的代码,图形看起来和book一样。我之前怀疑过这一点,但只是删除了目录中“name\u scope\u 1”的文件夹。稍后,我重新启动内核并再次运行代码,它也可以工作。@jdehesa:您能写一个答案吗?
tf.reset_default_graph()