import tensorflow as tf

"""
tf.get_variable()和Variable有很多不同点
* 它们对重名操作的处理不同
* 它们受name_scope的影响不同
"""
a = tf.Variable(3, name="a")
b = tf.Variable(3, name="a")
print(a.name, b.name) # a:0 a_1:0 try:
a = tf.get_variable("b", initializer=tf.constant_initializer(3), shape=1)
b = tf.get_variable("b", initializer=tf.constant_initializer(3), shape=1) # Variable b already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope?
except Exception as ex:
print(ex)

Tensorflow get_variable和Varialbe的区别的更多相关文章

  1. tensorflow 笔记12:函数区别:placeholder,variable,get_variable,参数共享

    一.函数意义: 1.tf.Variable() 变量 W = tf.Variable(<initial-value>, name=<optional-name>) 用于生成一个 ...

  2. tensorflow中的name_scope, variable_scope

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

  3. 第七节,TensorFlow编程基础案例-TensorBoard以及常用函数、共享变量、图操作(下)

    这一节主要来介绍TesorFlow的可视化工具TensorBoard,以及TensorFlow基础类型定义.函数操作,后面又介绍到了共享变量和图操作. 一 TesnorBoard可视化操作 Tenso ...

  4. 【PaddlePaddle系列】手写数字识别

      最近百度为了推广自家编写对深度学习框架PaddlePaddle不断推出各种比赛.百度声称PaddlePaddle是一个“易学.易用”的开源深度学习框架,然而网上的资料少之又少.虽然百度很用心地提供 ...

  5. tf.variable和tf.get_Variable以及tf.name_scope和tf.variable_scope的区别

    在训练深度网络时,为了减少需要训练参数的个数(比如具有simase结构的LSTM模型).或是多机多卡并行化训练大数据大模型(比如数据并行化)等情况时,往往需要共享变量.另外一方面是当一个深度学习模型变 ...

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

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

  7. tensorflow共享变量 the difference between tf.Variable() and get_variable()

    一般这样用tf.get_variable(): v = tf.get_variable(name, shape, dtype, initializer) 下面内容来源于 http://blog.csd ...

  8. 【TensorFlow基础】tf.add 和 tf.nn.bias_add 的区别

    1. tf.add(x,  y, name) Args: x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, ...

  9. tensorflow中run和eval的区别(转)

    在tensorflow中,eval和run都是获取当前结点的值的一种方式. 在使用eval时,若有一个 t 是Tensor对象,调用t.eval()相当于调用sess.run(t) 一下两段代码等效: ...

随机推荐

  1. MFC增强----任务对话框CTaskDialog类

    /** 注意:从Windows Vista系统才开始支持CTaskDialog类,所以在使用时最好调用 CTaskDialog::IsSupported() 方法做判断 同时:CTaskDialog类 ...

  2. GridViewColumn.CellTemplate

    <GridViewColumn Header="Sig" Width="210"> <GridViewColumn.CellTemplate& ...

  3. 【转】字符编码笔记:ASCII,Unicode 和 UTF-8

    原文:http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html https://www.key-shortcut.com/ ...

  4. 转: Centos安装gcc及g++

    Centos安装gcc及g++   Centos支持yum安装,安装软件一般格式为yum install .......,注意安装时要先成为root用户. 按照这个思路,我想安装过程如下: 安装gcc ...

  5. 利用OSG实现模拟飞机尾迹-粒子系统

    利用OSG实现模拟飞机尾迹-粒子系统 粒子系统简介:         粒子系统是用于不规则模糊物体建模及图像生成的一种方法.         粒子系统是一种过程模型,即利用各种计算过程生成模型各个体素 ...

  6. Log4net PatternLayout 参数

    Log4net PatternLayout 参数 来自: https://logging.apache.org/log4net/log4net-1.2.13/release/sdk/log4net.L ...

  7. [Functional Programming] Using Last monoid with Maybe

    Imaging we have a deck of cards, eveytimes we need to pick one card from deck, the result we want to ...

  8. sonarqube 5.6

    转载:https://www.jianshu.com/p/402987500bfd 一. 简介 Sonar是一个用于代码质量管理的开源平台,用于管理源代码的质量.通过插件形式,可以支持包括java,C ...

  9. mysql存储过程,游标实例

    CREATE DEFINER=`root`@`%` PROCEDURE `vir`.`task_payment_byonlinedown`()begin declare _mobile varchar ...

  10. Android Studio 之 打包生成的 apk 安装包装到手机上闪退

    今天,在 Android Studio 中的模拟器中测试 app 程序正常,然后打包 apk 安装包程序,发给领导后,领导反馈安装后打开闪退,抓紧安装到自己手机上,发现果然存在闪退.查阅资料后,解决方 ...