tf.Variable()
来源:互联网 发布:单片机软件原理 编辑:程序博客网 时间:2024/05/22 00:13
tf.Variable(initializer, name)
功能:保存和更新神经网络中的参数。
参数:(1)initializer:初始化参数(2)name:变量名
例子:
import tensorflow as tf #1.tensorflow随机数生成函数#变量a是一个随机生成的满足正态分布[0,1]的,数据规模为2*2矩阵的数据。其中mean表示为期望(均值),stddev表示为方差。a= tf.Variable(tf.random_normal(shape=[2,2], mean=0, stddev=1), name='a') #变量b是...,但如果随机出来的值偏离平均值超过2个标准差,那么这个数将会被重新随机。b=tf.Variable(tf.truncated_normal(shape=[2,2], mean=0, stddev=1),name='b')#变量c是一个随机生成的数据规模为2*2矩阵的数据,其中矩阵中的元素大小满足(-2,2)c=tf.Variable(tf.random_uniform(shape=[2,2],minval=-2,maxval=2,dtype=tf.float32,name='c'))#2.tensorflow常数生成函数e=tf.Variable(tf.zeros([1,2],tf.int32,name='e'))f=tf.Variable(tf.ones([3,4],tf.int32,name='f'))g=tf.Variable(tf.fill([5,6],1,name='g'))h=tf.Variable(tf.constant([1,2,3],name='h'))with tf.Session() as sess: sess.run(tf. global_variables_initializer()) print(sess.run(a)) print(sess.run(b)) print(sess.run(c)) print(sess.run(e)) print(sess.run(f)) print(sess.run(g)) print(sess.run(h))
结果:
[[-0.38980678 0.30893806]
[-0.98391175 1.02173746]]
[[-0.07013009 -1.07275367]
[ 0.43275923 -1.85455608]]
[[-0.0278039 0.88930941]
[ 0.15009832 1.51027441]]
[[0 0]]
[[1 1 1 1]
[1 1 1 1]
[1 1 1 1]]
[[1 1 1 1 1 1]
[1 1 1 1 1 1]
[1 1 1 1 1 1]
[1 1 1 1 1 1]
[1 1 1 1 1 1]]
[1 2 3]
阅读全文
0 0
- tf.Variable
- tf.Variable()
- tf.Variable()
- tf.Variable
- tf.name_scope&tf.variable scope
- TensorFlow--tf.Variable
- tensorflow API:tf.Variable
- tf.get_variable() vs tf.Variable(),tf.name_scope() vs tf.variable_scope()
- tf.get_variable() vs tf.Variable(),tf.name_scope() vs tf.variable_scope()
- TensorFlow 插曲-- tf.placeholder 与 tf.Variable
- tf.Variable()与tf.get_variable()与不同之处
- tf.Variable()与tf.get_variable()对比
- tf.Variable函数的用法
- TF中的tf.Variable 和 tf.placehold 的区别
- tensorflow variable_scope,tf.name_scope, tf.variable, tf.get_varible
- TF中的tf.Variable 和 tf.placehold 的区别
- TensorFlow 辨异 —— tf.placeholder 与 tf.Variable
- TensorFlow 辨异 —— tf.placeholder 与 tf.Variable
- 机器学习之逻辑回归 Logistic Regression(一)
- Android <activity-alias> 的用法
- java手动实现集合(数组形式)
- ffmpeg下载
- GIAC 2017全球互联网架构大会日程提前看!
- tf.Variable()
- 逻辑层 applicationContext-service.xml
- jsp页面与后台进行交流传值(java)
- 大白话讲解Promise(一)
- Java 并发之 ScheduledThreadPoolExecutor 原理分析
- poj 1063 找规律题目
- Hive中union使用详情
- 事物处理 applicationContext.xml
- AndroidStudio修改项目名称