如何知道我是否应该使用示例在name_scope或variable_scope中为Tensorboard包装操作

时间:2017-04-06 17:22:51

标签: machine-learning tensorflow deep-learning tensorboard

将可视化操作分组在一起时,下面两个程序之间生成的输出之间存在很大差异。 tf.name_scope提供双rnn输出,一个在name_scope内,一个在外,而tf.variable_scope给出更清晰的表示。我怎么知道我是否必须在变量与名称范围内包装一些东西(除get_variable的明显情况外)?

import tensorflow as tf

with tf.name_scope("bongo"):
    x = tf.placeholder(tf.float32,[1,None, 50], name='myxxxx')
    lstm = tf.contrib.rnn.BasicLSTMCell(77)
    drop = tf.contrib.rnn.DropoutWrapper(lstm, output_keep_prob=0.5)
    cell = tf.contrib.rnn.MultiRNNCell([drop] * 3)

    initial_state = cell.zero_state(33, tf.float32)

with tf.name_scope("alias"):
    outputs, final_state = tf.nn.dynamic_rnn(
        cell,
        x, dtype=tf.float32)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    fw = tf.summary.FileWriter('/tmp/testmodel/1', sess.graph)

import tensorflow as tf

with tf.name_scope("bongo"):
    x = tf.placeholder(tf.float32,[1,None, 50], name='myxxxx')
    lstm = tf.contrib.rnn.BasicLSTMCell(77)
    drop = tf.contrib.rnn.DropoutWrapper(lstm, output_keep_prob=0.5)
    cell = tf.contrib.rnn.MultiRNNCell([drop] * 3)

    initial_state = cell.zero_state(33, tf.float32)

with tf.variable_scope("alias"):
    outputs, final_state = tf.nn.dynamic_rnn(
        cell,
        x, dtype=tf.float32)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    fw = tf.summary.FileWriter('/tmp/testmodel/1', sess.graph)

0 个答案:

没有答案