1.tf.transpose(input, [0,2,1])
这个就表示 将input这个Tensor的第1个维度与第2个维度交换,交换之后便可以相乘
2. tf.abs(a) 这个就是取a里面的绝对值.
3. tf.sign(x)
如果x < 0,则有 y = sign(x) = -1;如果x == 0,则有 0 或者tf.is_nan(x);如果x > 0,则有1。如果x < 0,则有 y = sign(x) = -1;如果x == 0,则有 0 或者tf.is_nan(x);如果x > 0,则有1。
4. tf.tile(input, #输入 multiples, #某一维度上复制的次数 name=None )
# 如果只有 一个数,就表示在 第一维度(也就是列数)上面将原来的数复制2遍
temp = tf.tile([1,2,3],[2])
# 这个表示的在第一维度(也就是行数)上面将原来的数复制2遍
# 这个表示的在第一维度(也就是列数)上面将原来的数复制3遍
temp2 = tf.tile([[1,2],[3,4],[5,6]],[2,3])
with tf.Session() as sess:
print(sess.run(temp))
print(sess.run(temp2))
---------------------
[1 2 3 1 2 3]
[[1 2 1 2 1 2]
[3 4 3 4 3 4]
[5 6 5 6 5 6]
[1 2 1 2 1 2]
[3 4 3 4 3 4]
[5 6 5 6 5 6]]
5. tf.ones_like(tensor, dtype = none)
将Tensor里面的值全部设置成 1
6 tf.equal(A, B)
A = [[1,3,4,5,6]]
B = [[1,3,4,3,2]]
with tf.Session() as sess:
print(sess.run(tf.equal(A, B)))
输出:
[[ True True True False False]]
7.tf.where(condition, x=None, y=None,name=None),condition是一个true和false的集合
当condition 的值为 true时,就在x的对应位置找值
当condition 的值为 false时,就在y的对应位置找值
这个就意味着 condition3 的维度必须和x,y一样
x = [[1,2,3],[4,5,6]]
y = [[7,8,9],[10,11,12]]
condition3 = [[True, False, False],
[False, True, True]]
condition4 = [[True, False, False],
[True, True, False]]
with tf.Session() as sess:
print(sess.run(tf.where(condition3,x,y)))
print(sess.run(tf.where(condition4,x,y)))
[[ 1 8 9]
[10 5 6]]
[[ 1 8 9]
[ 4 5 12]]
&spm=1001.2101.3001.5002&articleId=85236769&d=1&t=3&u=e3ec541917974341a48790130f259874)
2227

被折叠的 条评论
为什么被折叠?



