Advertisement

namespace-graph nodes in TensorBoard

阅读量:

一,命名空间函数
tf.variable_scope
tf.name_scope
以下代码将用于阐述二者之间的差异

复制代码
     # 命名空间管理函数
    '''
    说明tf.variable_scope和tf.name_scope的区别
    '''
    def manage_namespace():
    with tf.variable_scope("foo"):
        # 在命名空间foo下获取变量"bar",于是得到的变量名称为"foo/bar"。
        a = tf.get_variable("bar",[1])   #获取变量名称为“bar”的变量
        print a.name       #输出:foo/bar:0
    with tf.variable_scope("bar"):
        # 在命名空间bar下获取变量"bar",于是得到的变量名称为"bar/bar"。
        a = tf.get_variable("bar",[1])
        print a.name       #输出:bar/bar:0
    with tf.name_scope("a"):
        # 使用tf.Variable函数生成变量会受tf.name_scope影响,于是得到的

全部评论 (0)

还没有任何评论哟~