2017-06-03 10 views
1

以下是一些tf.constant顯示在tensorboard中的工作代碼,有些不顯示。當'tf.constant`沒有顯示在'tensorboard'中時,令人困惑的情況是什麼?

但是,我不知道爲什麼這些不顯示。

誰能幫我在這裏?謝謝

import tensorflow as tf 
import numpy as np 
# tf.constant(value, dtype=None, shape=None, 
# name='Const', verify_shape=False) 


a = tf.constant([2, 2], name="a") 
b = tf.constant([[0, 1], [2, 3]], name="b") 
x = tf.add(a, b, name="add") 
y = tf.multiply(a, b, name="mul") 

# verify_shape=True, error if shape not match 
# edge1 = tf.constant(2, dtype=None, shape=[2,2], name="wrong_shape", verify_shape=True) 


# verify_shape=False, if shape not match, will add to match 
edge2 = tf.constant(2, dtype=None, shape=[2,2], name="edge2", verify_shape=False) 
# increase row by row, from left to right 
edge3 = tf.constant([1,2,3,4], dtype=None, shape=[4,3], name="edge3", verify_shape=False) 

# reassign works 
edge2c = edge2 
edge3c = edge3 

edge4 = tf.constant(np.ones((2,2)), dtype=None, shape=None, name="shape22", verify_shape=False) 
# increase row by row, from left to right 
edge5 = tf.constant(np.ones((4,3)), dtype=None, shape=[4,3], name="shape43", verify_shape=False) 


with tf.Session() as sess: 
    writer = tf.summary.FileWriter('./log/01_tf', sess.graph) 
    x, y = sess.run([x, y]) 
    sess.run(edge4) 
    sess.run(edge5) 
    sess.run(edge2c) 
    sess.run(edge3c) 

writer.close() 
+0

您不必重複使用'sess.run',實際上它將所有事件異步存儲到事件文件中。即使刪除所有'sess.run',該圖形也不會顯示任何差異。 –

+0

謝謝!你是對的。 – Daniel

回答

0

我明白了。

要顯示張量板中的任何節點,必須首先在操作中使用節點。作爲tf.constant而不涉及addmultiply或任何其他操作,將不會顯示在張量板上。