1.作用:逐个元素相减。
tf.math.subtract(
x, y, name=None
)
输入:
x:一个tensor
y:跟x同类型的tensor
例子:
import tensorflow as tf
a = tf.constant([[3]]) #广播为:[[3, 3], [3, 3]]
b = tf.constant([[1, 6], [2, 9]])
c = tf.subtract(a, b)
sess = tf.Session()
print sess.run(c)
输出:
[[ 2 -3]
[ 1 -6]]