115、TensorFlow变量的使用
# To use the value of a tf.Variable in a Tesnorflow graph , simply treat it like a normal tf.Tensor
import tensorflow as tf
v = tf.get_variable("v", shape=(), initializer=tf.zeros_initializer())
w = v + 1 # w is a tf.Tensor which is computed based on the value of v
# Any time a variable is used in an expression it gets automatically
# converted to a tf.Tensor representing its value
# To assign a value to a variable , use the methods assign , assign_add
# and friends in the tf.Variable class . For example
v1 = tf.get_variable("v1", shape=(), initializer=tf.zeros_initializer())
assignment = v1.assign_add(1)
with tf.Session() as sess:
tf.global_variables_initializer().run()
print(sess.run(assignment))
下面是输出的结果
2018-02-17 10:55:36.215165: I C:\tf_jenkins\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
1.0
115、TensorFlow变量的使用的更多相关文章
- tensorflow变量-【老鱼学tensorflow】
在程序中定义变量很简单,只要定义一个变量名就可以,但是tensorflow有点类似在另外一个世界,因此需要通过当前的世界中跟tensorlfow的世界中进行通讯,来告诉tensorflow的世界中定义 ...
- tensorflow变量
tensorflow变量: 1.神经网络中的参数权重,偏置等可以作为张量保存到tensorflow的变量中 2.tensorflow变量必须被初始化 3.可被保存到文件中,下次使用重新加载即可 ten ...
- tensorflow变量的使用(02-2)
import tensorflow as tf x=tf.Variable([1,2]) a=tf.constant([3,3]) sub=tf.subtract(x,a) #增加一个减法op add ...
- Tensorflow 变量的共享
https://github.com/chenghuige/tensorflow-exp/blob/master/examples/sparse-tensor-classification/ tens ...
- 神经网络参数与TensorFlow变量
在TensorFlow中变量的作用是保存和更新神经网络中的参数,需要给变量指定初始值,如下声明一个2x3矩阵变量 weights =tf.Variable(tf.random_normal([2,3] ...
- tensorflow变量作用域(variable scope)
举例说明 TensorFlow中的变量一般就是模型的参数.当模型复杂的时候共享变量会无比复杂. 官网给了一个case,当创建两层卷积的过滤器时,每输入一次图片就会创建一次过滤器对应的变量,但是我们希望 ...
- TF Boys (TensorFlow Boys ) 养成记(三): TensorFlow 变量共享
上次说到了 TensorFlow 从文件读取数据,这次我们来谈一谈变量共享的问题. 为什么要共享变量?我举个简单的例子:例如,当我们研究生成对抗网络GAN的时候,判别器的任务是,如果接收到的是生成器生 ...
- 118、TensorFlow变量共享(二)
import tensorflow as tf # 在不同的变量域中调用conv_relu,并且声明我们想创建新的变量 def my_image_filter(input_images): with ...
- 117、TensorFlow变量共享
# sharing variables # Tensorflow supports two ways of sharing variables # 1.Explicitly passing tf.Va ...
随机推荐
- UVAlive 6763 Modified LCS
LCS stands for longest common subsequence, and it is a well known problem. A sequence in thisproblem ...
- 详解Twitter开源分布式自增ID算法snowflake(附演算验证过程)
详解Twitter开源分布式自增ID算法snowflake,附演算验证过程 2017年01月22日 14:44:40 url: http://blog.csdn.net/li396864285/art ...
- 67.Task Scheduler(任务规划)
Level: Medium 题目描述: Given a char array representing tasks CPU need to do. It contains capital letter ...
- NGUI的CheckBox的使用(toggle script)
一,我们先添加一个sprite,选择sprite,右键选择attach,添加box collider, 然后右键选择attach,添加toggle script,得到如下图结果 1,但是如果你没有给U ...
- Quartz的简单使用
一.Quartz 介绍 Quartz是Java领域最著名的.功能丰富的.开放源码的作业调度工具,几乎可以在所有的Java应用程序中集成--从小的单机应用到大的电子商务系统. Quartz可以用来执行成 ...
- vue项目一个页面使用多个轮播图详解
1.html代码: <div v-for="(item,index) in arrDataList.Floor"> // 根据后台数据循环渲染多个轮播图组件 <d ...
- es5和es6中的this指向问题
const test ={ id:2, a:function(){ var a_this=this; setTimeout(function(){ console.log('a:',this,a_th ...
- EBCDIC 870 Poland
Characters are shown with their equivalent Unicode codes.
- java通过反射拿到mybatis中的sql语句并操作
private static final int MaxBatchLength = 100; public void updateBatch(List<T>list, BaseMapper ...
- MySQL MHA + Ifconfig管理vip
前期的安装步骤,还是参照:http://www.cnblogs.com/yiyuf/p/4104354.html进行,只需要把appxxx.cnf中定义的相关.sh脚本(如:master_ip_fai ...