1.with tf.variable_scope(name , reuse = reuse)

(1)创建variable scope

with tf.variable_scope("foo"):
with tf.variable_scope("bar"):
v = tf.get_variable("v", [1])
assert v.name == "foo/bar/v:0"

(2)共享变量

with tf.variable_scope("foo"):
v = tf.get_variable("v", [1])
with tf.variable_scope("foo", reuse=True):
v1 = tf.get_variable("v", [1])
assert v1 == v

(3)在一个变量域中,不允许重用变量

with tf.variable_scope("foo"):
v = tf.get_variable("v", [1])
v1 = tf.get_variable("v", [1])
# Raises ValueError("... v already exists ...").

(4)当试图获取在重用模式中不存在的变量时,我们会引发异常

with tf.variable_scope("foo", reuse=True):
v = tf.get_variable("v", [1])
# Raises ValueError("... v does not exists ...").

tensorflow--variable_scope的更多相关文章

  1. tensorflow中的name_scope, variable_scope

    在训练深度网络时,为了减少需要训练参数的个数(比如LSTM模型),或者是多机多卡并行化训练大数据.大模型等情况时,往往就需要共享变量.另外一方面是当一个深度学习模型变得非常复杂的时候,往往存在大量的变 ...

  2. TensorFlow学习笔记(1):variable与get_variable, name_scope()和variable_scope()

    Variable tensorflow中有两个关于variable的op,tf.Variable()与tf.get_variable()下面介绍这两个的区别 使用tf.Variable时,如果检测到命 ...

  3. tensorflow入门笔记(五) name_scope和variable_scope

    一.上下文管理器(context manager) 上下文管理器是实现了上下文协议的对象,主要用于资源的获取与释放.上下文协议包括__enter__.__exit__,简单说就是,具备__enter_ ...

  4. 【TensorFlow学习笔记 】name_socpe variable_scope

    [引言]TensorFlow中的命名域是非常重要的概念,涉及到参数共享,方便命名参数管理,定义图结构 本文主要介绍name_scope 和 variable_scope,slim包中的arg_scop ...

  5. Tensorflow函数——tf.variable_scope()

    Tensorflow函数——tf.variable_scope()详解 https://blog.csdn.net/yuan0061/article/details/80576703 2018年06月 ...

  6. Tensorflow中的name_scope和variable_scope

    Tensorflow是一个编程模型,几乎成为了一种编程语言(里面有变量.有操作......). Tensorflow编程分为两个阶段:构图阶段+运行时. Tensorflow构图阶段其实就是在对图进行 ...

  7. tensorflow里面共享变量、name_scope, variable_scope等如何理解

    tensorflow里面共享变量.name_scope, variable_scope等如何理解 name_scope, variable_scope目的:1 减少训练参数的个数. 2 区别同名变量 ...

  8. TensorFlow入门(四) name / variable_scope 的使

    name/variable_scope 的作用 欢迎转载,但请务必注明原文出处及作者信息. @author: huangyongye @creat_date: 2017-03-08 refer to: ...

  9. TensorFlow基础笔记(13) tf.name_scope tf.variable_scope学习

    转载http://blog.csdn.net/jerr__y/article/details/60877873 1. 首先看看比较简单的 tf.name_scope(‘scope_name’). tf ...

  10. tensorflow中共享变量 tf.get_variable 和命名空间 tf.variable_scope

    tensorflow中有很多需要变量共享的场合,比如在多个GPU上训练网络时网络参数和训练数据就需要共享. tf通过 tf.get_variable() 可以建立或者获取一个共享的变量. tf.get ...

随机推荐

  1. linux 替换 sed命令 转载

    转载自这里,感谢原作者 sed 's/test/mytest/g' example.txt 表示将example.txt中的test文本全部替换为mytest 请注意这个命令sed 's/test/m ...

  2. DNS搜索

    dig(Domain Information Groper) dig @dnsserver name querytype 如果你设置的dnsserver是一个域名,那么dig会首先通过默认的上连DNS ...

  3. (4.4)mysql备份还原——备份存储容灾基础知识

    存储知识 1.为什么需要存储,存储一般解决哪些问题? 容量.速度.易于管理.安全(容灾与备份).可扩展性 2.存储发展历史 [2.1]大型机 [2.2]c/s结构(客户端->服务器) [2.3] ...

  4. wordpress去掉category怎么操作让url更简洁友好

    用wordpress建站是比较流行的,全球将近25%的站点是用wordpress搭建的.有很多的模板.插件可以选择,当然最好还是能自己优化.URL固定链接就是之中一个基础的技巧.有网友问如何去掉url ...

  5. OCP-第二节课.md

    第一. MQ(压队列)    PGA    share pool 三层结构 应用服务器--->中间件--->数据库 第二. TCP/IP 第三. 应用层:应用层.表示层.会话层 数据流层: ...

  6. xshell中alt+.不能用问题

  7. mysql 远程登录 设置

    1.在服务器上通过命令行或客户端登录mysql:2.执行以下sql:GRANT ALL PRIVILEGES ON 开放权限的数据库.* TO 用户名@"%" IDENTIFIED ...

  8. VS中属性配置ABC

    1.包含目录和附加包含目录(库目录和附加库目录)的区别: 包含目录:修改了系统的include宏的值,是全局的: 附加包含目录:用于当前项目,对其他项目没有影响. (库目录和附加库目录的区别同上) 2 ...

  9. 异常处理的捕捉:try{}catch(异常类 变量)finally{最终执行}

    可以对异常进行针对性处理的方式.try{ //需要被检查的异常 }catch(异常类  变量)//该变量用于接收发生的异常{ //处理异常的代码 }finally{ //一定会被执行的代码. }

  10. 亚马逊IOT-SDK,线程池数

    1111