tensorlfow
千千Sama
这个作者很懒,什么都没留下…
展开
-
tf.train.exponential_decay()用法
tf.train.exponential_decay()官网链接tf.train.exponential_decay( learning_rate, global_step, decay_steps, decay_rate, staircase=False, name=None)一句话描述:对学习率learning_rate应用指数衰减。多...原创 2018-11-15 20:41:02 · 11966 阅读 · 3 评论 -
tf.reduce_max()详解
官网文档https://tensorflow.google.cn/api_docs/python/tf/math/reduce_maximport tensorflow as tfimport numpy as npa=np.array([[1, 2], [5, 3], [2, 6]])b = tf.Variable(a)with t...原创 2018-12-29 22:25:28 · 21875 阅读 · 5 评论 -
tf.stack详解
官方文档:https://tensorflow.google.cn/api_docs/python/tf/stack把一些秩为R的Tensor堆叠成R+1。给定一个元素shape为(A,B,C)的Tensor的列表,列表长度为N,则若axis==0,shape=(N, A, B, C)若axis==1,shape=(A, N, B, C)tf.stack( values, ...原创 2018-12-29 23:02:42 · 1283 阅读 · 0 评论 -
tf.shape详解
官网链接https://tensorflow.google.cn/api_docs/python/tf/shapetf.shape( input, name=None, out_type=tf.int32)返回一个一维整数Tensor,用以表示输入input的shapetf.shape( input, name=None, out_typ...原创 2018-12-29 23:44:20 · 6674 阅读 · 2 评论 -
tf.range详解
官网链接https://tensorflow.google.cn/api_docs/python/tf/rangetf.range(limit, delta=1, dtype=None, name='range')tf.range(start, limit, delta=1, dtype=None, name='range')以start为起点,delta为变化量,生成不超过,且不包含l...原创 2018-12-30 16:55:44 · 6137 阅读 · 0 评论 -
tf.gather_nd详解
官网链接https://tensorflow.google.cn/api_docs/python/tf/gather_ndtf.gather_nd( params, indices, name=None)按照indices的格式从params中抽取切片(合并为一个Tensor)indices是一个K维整数Tensor,例子1import tensorflow...原创 2018-12-30 20:41:20 · 13538 阅读 · 0 评论 -
tf.math.squared_difference详解
官网链接https://tensorflow.google.cn/api_docs/python/tf/math/squared_differencetf.math.squared_difference( x, y, name=None)例子import tensorflow as tfa=tf.constant([0, 2, 3, 1,1])b=tf.c...原创 2018-12-30 22:24:38 · 1495 阅读 · 0 评论 -
tf.math.reduce_mean详解
官网链接https://tensorflow.google.cn/api_docs/python/tf/math/reduce_meantf.math.reduce_mean( input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None, # 废弃 keep...原创 2018-12-30 22:36:24 · 2603 阅读 · 0 评论 -
tf.get_variable()用法详解
https://www.tensorflow.org/api_docs/python/tf/get_variable?hl=en获取一个已经存在的变量(给定参数),或者,创建一个新的原创 2019-03-14 16:57:57 · 1954 阅读 · 0 评论 -
tf.Variable用法详解
https://tensorflow.google.cn/api_docs/python/tf/Variable通过创建Variable类的实例向graph中添加变量。Variable()需要初始值,一旦初始值确定,那么该变量的类型和形状都确定了。更改值通过assign方法。想要改变形状,需要使用assign+validate_shape=False。想要运行graph,必须先显式初始化...原创 2019-03-12 23:49:10 · 7326 阅读 · 0 评论 -
tf.squared_difference
官网文档:https://www.tensorflow.org/versions/r1.9/api_docs/python/tf/squared_difference?hl=en其实很简单tf.squared_difference( x, y, name=None)按元素求(x-y)²。import tensorflow as tfx = tf.consta...原创 2019-05-02 16:33:56 · 415 阅读 · 0 评论 -
tf.GraphKey简介
官方文档链接:https://www.tensorflow.org/api_docs/python/tf/GraphKeys#GLOBAL_VARIABLES公有以下标准键:GLOBAL_VARIABLESLOCAL_VARIABLESMODEL_VARIABLESTRAINABLE_VARIABLES:tf.Optimizer子类默认优化该类下的变量SUMMARIESQUEUE_...原创 2018-12-28 18:19:01 · 592 阅读 · 0 评论 -
tensorflow中变量如何赋值及初始化系统讲解
Tensorflow中的变量初始化有两类方法:使用xxxx()方法生成一个Tensor, 将这个Tensor作为tf.Variable()中的initial_value参数的入参, 来初始化这个变量;使用xxxx_initializer()创建一个初始化方法, 指明一种初始化的方法, 但并不生成具体的Tensor, 使用在tf.get_variable()和tf.variable_scope...原创 2018-12-27 21:36:47 · 2680 阅读 · 1 评论 -
v:0 v1:0 v:0 v1:0 global_step:0和tf.global_variables()区别
import tensorflow as tfv = tf.Variable(tf.constant(0.0, shape=[1], dtype=tf.float32), name='v')v1 = tf.Variable(tf.constant(5, shape=[1], dtype=tf.float32), name='v1')global_step = tf.Variable(tf...原创 2018-12-09 16:52:09 · 295 阅读 · 0 评论 -
tensorflow常用API解读——layers.l1_regularizer(),layers.l1_regularizer()
import tensorflow as tfimport tensorflow.contrib as contribweight = tf.constant([[1.0, -2.0], [-3.0, 4.0]])with tf.Session() as sess: # 输出为(|1|+|-2|+|-3|+|4|)*0.5=5 print(sess.run(contrib....原创 2018-11-20 21:02:25 · 676 阅读 · 0 评论 -
tensorflow常用API解读——tf.add_to_collection,tf.get_collection,tf.add_n
*tf.add_to_collection(‘list_name’, element):将元素element添加到列表list_name中*tf.get_collection(‘list_name’):返回名称为list_name的列表*tf.add_n(list):将列表元素相加并返回import tensorflow as tftf.add_to_collection('losses'...原创 2018-11-20 20:18:42 · 1005 阅读 · 0 评论 -
tensorflow常用API解读——tf.equal()
官网链接解读tf.equal(x,y)输入两个Tensor,两个Tensor的形状必须一致,按元素判断是否一致,返回真值矩阵。import tensorflow as tfimport numpy as npx=np.array([[1,2], [3,4]])y=np.array([[1,2], [5,6]])truth=tf.eq...原创 2018-11-22 17:02:02 · 557 阅读 · 0 评论 -
tensorlfow常用API解读——tf.argmax()
其实该函数很简单——输出Tensor沿着给定axis的最大值的索引。官方文档中说axis要为Tensor,但是实际上直接给定实数就可以。import tensorflow as tfimport numpy as npA = np.array([[31, 23, 4, 24, 27, 34], [18, 3, 25, 0, 6, 35], ...原创 2018-11-22 21:33:15 · 278 阅读 · 0 评论 -
tensorflow学习笔记——tf.assign(),tf.assing_add(),tf.assing_sub()
tf.assign( ref, value, validate_shape=None, use_locking=None, name=None)作用:把value分配给ref。N.B.:①若该语句未run,则不分配。②是更新值,而不是重新赋给一个变量③该语句会初始化ref变量。关于①,看如下例子import tensorflow as tf...原创 2018-11-17 17:09:52 · 272 阅读 · 0 评论 -
tensorflow学习笔记——tf.Variable.eval
print(sess.run(a))等价于print(a.eval())原创 2018-11-17 17:27:11 · 423 阅读 · 0 评论 -
tf.math.exp详解
官方文档:https://www.tensorflow.org/api_docs/python/tf/math/exptf.math.exp( x, name=None)输入x,输出exe^{x}ex。数据类型必须是bfloat16, half, float32, float64, complex64, complex128例子:import tensorflow a...原创 2019-05-20 16:58:59 · 3492 阅读 · 1 评论