摘要: 1.tf.pad(tensor,[[1a,1b],[2a,2b]...]):将tensor中的第n个维度上下分别增加na和nb个值 example: input: a=tf.random.uniform([2,2],maxval=5,minval=1,dtype=tf.int32)b=tf.pad( 阅读全文
posted @ 2020-11-03 21:41 ladadee 阅读(124) 评论(0) 推荐(0)
摘要: 1.tf.sort(tensor,direction='DESCENDING'):将tensor的每一行元素按升序或倒序排列,有direction='DESCENDING'时为降序,不写时为升序 example: input: import tensorflow as tfa=tf.random.s 阅读全文
posted @ 2020-10-20 22:14 ladadee 阅读(228) 评论(0) 推荐(0)
摘要: 1.tf.concat([a,b],axis=a):在第a维度上将tensor a与b进行合并。 example: input: a=tf.ones([2,5,6])b=tf.ones([3,5,6])c=tf.concat([a,b],axis=0)print(c.shape) output: ( 阅读全文
posted @ 2020-10-12 22:23 ladadee 阅读(467) 评论(0) 推荐(0)
摘要: 相较于tf.expand_dim、tf.tile,broadcasting,broadcasting使用更加简洁,并且更加节省内存空间。 broadcasting作为tensor运算时的一种优化手段,会在进行运算的tensor满足一定条件时自动进行优化,也可使用tf.broadcast_to将ten 阅读全文
posted @ 2020-10-05 21:31 ladadee 阅读(238) 评论(0) 推荐(0)
摘要: 1.tf.reshape(tensor,[newshape]):将原来的tensor变换为指定的新的维度,元素个数不发生变化(一般用于维度合并) examples: input: a=tf.random.normal([4,28,28,3])b=tf.reshape(a,[4,-1,3])print 阅读全文
posted @ 2020-10-05 20:29 ladadee 阅读(417) 评论(0) 推荐(0)
摘要: 1.直接通过维度编号进行索引 example: input: a=tf.random.uniform([2,2,6,3],minval=0,maxval=20,dtype=tf.int32)print(a,"\n",a[0][0])这里a[0][0]也可以写作a[0,0] output: tf.Te 阅读全文
posted @ 2020-10-05 12:09 ladadee 阅读(291) 评论(0) 推荐(0)
摘要: Tensor的创建: 1. tf.convert_to_tensor():使用numpy创建并转化为tensor或者直接创建tensor examples: input: tf.convert_to_tensor(np.ones([3,3])) output: tf.Tensor( [[1. 1. 阅读全文
posted @ 2020-10-04 15:46 ladadee 阅读(166) 评论(0) 推荐(0)