通俗理解 tf.name_scope() tf.variable_scope()

************************************原文   https://blog.csdn.net/feifei_csdn/article/details/99678974   *******************************************************

name_scope   variable_scope是两个作用域函数,一般与两个创建 调用变量的函数tf.variable   get_variable搭配使用

经常用于  

变量共享    tensorboard画流程图进行可视化封装变量

通俗地理解就是    tf.name_scope  tf.variable_scope会在模型中开启各自的空间,其中的变量均在这个空间内进行管理,但是二者是有各自的区别

1  name_scope  variable_scope

命名域name_scope通过tf.name_scope或者  tf.op_scope创建

变量域variable_scope,通过tf.name_scope或者tf.variable_op_scope创建

这两种作用域,对于使用tf.Variable()方式创建的变量,具有相同的效果,都会在变量名称前面,加上域名称

 

 

2   tf.name_scope()命名空间的实际作用

1  在某个tf.name_scope()指定的区域中定义的所有对象及各种操作,他们的name属性上会增加该命名域的区域名,用于区别对象属于哪个区域

2   将不同的对象及操作放在tf.name_scope()指定的区域中,便于在tensorboard中展示清晰的逻辑关系图,这点在复杂关系图中特别重要。

3   name_scope()只决定对象属于哪个范围,并不会对 对象的作用域产生任何影响。

 

posted @ 2021-08-16 18:44  大大的海棠湾  阅读(82)  评论(0)    收藏  举报