
tensorflow基本函数
想好当码农了嘛
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
tf.variable_scope()与tf.get_variable()获取已经创建的变量
代码来自《TensorFlow实战Google深度学习框架(第2版)》,直接上例子:#在名字为foo的命名空间内创建名字为v的变量with tf.variable_scope("foo"): v = tf.get_variable("v", [1], initializer=tf.constant_initializer(1.0))#以下代码会报错,因为命名空间foo中已经存在名字...原创 2019-10-20 18:14:07 · 498 阅读 · 0 评论 -
tf.get_variable()和tf.Variable()
这两个函数都可以创建一个变量,举例:#以下两个定义等价v = tf.get_variable("v",shape=[1], initializer=tf.constant_initializer(1.0))v = tf.Variable(tf.constant(1.0,shape=[1]),name="v")注意:tf.Variable()的name可以省略,tf.get_va...原创 2019-10-20 17:26:33 · 177 阅读 · 0 评论 -
tf.transpose()
B = tf.transpose(A)#若A为二维数组,则此句表示对A转置得到B若A为更高维数组,用到再说。原创 2019-10-20 17:10:18 · 143 阅读 · 0 评论 -
tf.concat()
函数原型:tf.concat([tensor1, tensor2, tensor3,...], axis)tensorflow中用于拼接张量。举例: t1 = [[1, 2, 3], [4, 5, 6]] t2 = [[7, 8, 9], [10, 11, 12]] tf.concat([t1, t2], 0) # [[1, 2, 3], [4, 5, 6], [7, 8, ...原创 2019-10-20 17:00:23 · 225 阅读 · 0 评论 -
tf.newaxis
给tensor增加维度import tensorflow as tfa = tf.range(10,dtype=tf.int32)print(a)b = a[:,tf.newaxis]print(b)a的shape为(10,)b的shape为(10,1)若b = a[newaxis,:],则b的shape为(1,10)...原创 2019-09-10 20:25:58 · 3302 阅读 · 0 评论 -
tf.tile()
在同一维度上的复制:tile( input, multiples, name=None)multiples的维度应与input相同。举例接上一篇tf.newaxis:import tensorflow as tfa = tf.range(10,dtype=tf.int32)print(a)b = a[:,tf.newaxis]print(b...原创 2019-09-10 20:35:25 · 203 阅读 · 0 评论