I am reading Sam-Abrahams tensorflow book. While reading, I got the following code,
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()
as an example of the name scope. While I load it to the tensorboard I got the following image,
But sadly the book suggested a different image,
I know the book is pretty old and not everything is similar now. But judging from the code and figure something looks suspicious in figure 1,
with tf.name_scope("Scope_A"):
a = tf.add(1, 2, name="A_add")
b = tf.multiply(a, 3, name="A_mul")
for given "SCOPE_A", blue box is ok as there is both add and multiply operation.
but for the following code,
with tf.name_scope("Scope_B"):
c = tf.add(4, 5, name="B_add")
d = tf.multiply(c, 6, name="B_mul")
There is no multiply operation defined.
At the right side, there are some auxiliary nodes. From SCOPE_A_[0-15],SCOPE_B_[0-15]. What are they?
And Finally the most important question,
How can I generate a more clear graph like author generated in figure 2.
*UPD And Suggestion : *
1. never forget to reset the graph if you are working on the default graph.
tf.reset_default_graph()
2. Try to work with your defined graph. It's the most safest option to avoid this type of situation.
It seems that the graph you are showing is not really the one for that snippet; as you suspect, the correct graph is the one from the book. Make sure the logs directory is cleared before running the code and that you are not running anything before or after that (e.g. just open an interpreter, run the code and close it).