math_ops函数使用:
1、tf.add(x, y, name=None)
功能:对应位置元素的加法运算。
输入:x, y具有相同尺寸的tensor, 可以为half, float32, float64, unit8, int8, int16, int32, int64,
eg:
1、x = tf.constant(1.0)
2、y = f.constant(2.0)
3、z = tf.add(x, y)
z ==> (3.0)
2、tf.subtract(x, y, name=None)
功能:对应位置元素的减法运算。
输入:x, y具有相同尺寸的tensor, 可以为half, float32, float64, int32, int64,complex64, complex128, string类型。
1、x = tf.constant([1.0, -1.0], tf.float64)
2、y = f.constant([2.2, 2.3], tf.float64)
3、z = tf.subtract(x, y)
z ==> [[-1.2, -3.3]]
3、tf.multiply(x, y, name=None)
功能:对应位置元素的乘法运算。
输入:x, y具有相同尺寸的tensor,可以为half, float32, float64, uint8,int8, uint16, int16, int32, int64, complex64, complex128, string类型。
1、x = tf.constant([1.0, -1.0], tf.float64)
2、y = f.constant([2.2, 2.3], tf.float64)
3、z = tf.subtract(x, y)
z ==> [[2.2, -2.3]]
4、tf.scalar_mul(scalar, x)
将标量乘以一个张量(Tensor)或IndexedSlices对象。
参数 scalar:0-D的标量Tensor.必须有已知形状
x:要缩放的张量(Tensor)或IndexedSlices
返回值: 返回与x相同类型(Tensor或IndexedSlices)的标量*x