tf.name_scope 与 tf.variable_scope 对 tf.get_variable 与 tf.Variable 的影响

tf.name_scope 对 tf.get_variable 与 tf.Variable 的影响

  • tf.Variable 会加上 name_scope 的名字前缀, tf.get_variable 不会(同时以为 tf.get_variable 没有加 name_scope 的前缀,所以是全局变量,不在 name_scope 中,也无法 get_variable 创建同样的 name 的变量)


    image.png

tf.variable_scope 对 tf.get_variable 与 tf.Variable 的影响

  • tf.Variable 会加上 variable_scope 的名字前缀,tf.Variable碰到相同的变量会自动加名字, tf.get_variable 也会(同时以为 tf.get_variable 加 variable_scope 的前缀,同一个variable_scope中,只可以创作一个 name 的 get_variable, 如果需要variable_scope中共享同一个 name 的get_variable,需要设置参数 reuse=True)


    image.png
image.png
image.png
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。