
Tensorflow-API
Elag
勿以恶小而为之 勿以善小而不为
展开
-
Tensorflow-API : tf.gather
tf.gather 根据索引从参数轴上收集切片,索引必须是任何维度的整数张量 (通常为 0-D 或 1-D) import tensorflow as tf t1 = tf.reshape(tf.range(0,16),[2,2,4]) # [[[ 0 1 2 3] # [ 4 5 6 7]] # # [[ 8 9 10 11] # [12 13 14 15]...原创 2018-05-23 16:05:26 · 407 阅读 · 0 评论 -
Tensorflow-API :比较函数
比较两个数,返回一个 bool 类型的张量 import tensorflow as tf #判断每一个数是否大于0.5 greater = tf.greater([1.,0.2,0.5,0.,2.,3.], 0.5) #判断每一个数是否小于0.5 less = tf.less([1.,0.2,0.5,0.,2.,3.], 0.5) #判断每一个数是否大于等于0.5 greater_equal=...原创 2018-05-23 16:22:43 · 6830 阅读 · 0 评论 -
Tensorflow-API :tf.where
返回输入矩阵中true的索引位置,x和y必须同时有(维度必须相同)或没有 import tensorflow as tf where = tf.where([True,False,True,False,True,True]) where1 = tf.where([True,False,True,False,True,True],x=[1.,0.2,0.5,0.,2.,3.],y=[1,2,3,...原创 2018-05-23 16:36:37 · 448 阅读 · 0 评论 -
Tensorflow-API :tf.stack()和tf.unstack()
tf.stack():矩阵拼接 tf.unstack():矩阵分解 import tensorflow as tf a = tf.reshape(tf.range(0, 12), [3, 4]) b = tf.reshape(tf.range(100, 112), [3, 4]) # 按第0维拼接 stack0 = tf.stack([a, b], axis=0) # 按第1维拼接 ...原创 2018-05-24 06:37:06 · 563 阅读 · 0 评论 -
Tensorflow-API :tf.cond
tf.cond()是一个条件函数,根据条件返回的True或False 返回相应的结果 第一个参数是条件 bool 类型,第2个和第3个参数是返回的值,如果条件是True 返回第二个参数,如果条件是False 则返回第三个参数 import tensorflow as tf a = tf.constant(2) b = tf.constant(3) x = tf.constant(4) y =...原创 2018-05-24 10:22:10 · 459 阅读 · 0 评论