tf.add(x,y,name = None)求和函数
示例代码如下:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
x = 1
y = 2
a = tf.add(x,y)
with tf.Session() as sess:
print(sess.run(a))
tf.subtract(x,y,name = None)减法函数
示例代码如下:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
x = 1
y = 2
a = tf.subtract(x,y)
with tf.Session() as sess:
print(sess.run(a))
tf.multiply(x,y,name = None)乘法函数
示例代码如下:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
x = 3
y = 2
a = tf.multiply(x,y)
with tf.Session() as sess:
print(sess.run(a))
tf.div(x,y,name = None)除法函数
示例代码如下:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
x = 6
y = 2
a = tf.div(x,y)
with tf.Session() as sess:
print(sess.run(a))
tf.mod(x,y,name = None)取余函数
示例代码如下:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
x = 10
y = 4
a = tf.mod(x,y)
with tf.Session() as sess:
print(sess.run(a))
tf.abs(x,name = None)求绝对值函数
示例代码如下:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
x = -10
a = tf.abs(x)
with tf.Session() as sess:
print(sess.run(a))
tf.negative(x,name = None)取负函数
示例代码如下:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
x = -10
y = [5,6,7]
a = tf.negative(x)
b = tf.negative(y)
with tf.Session() as sess:
print(sess.run(a))
print(sess.run(b))
tf.square(x,name = None)计算平方函数
tf.round(x,name = None)四舍五入
tf.sqrt(x,name = None)开根号函数
tf.pow(x,y,name = None)幂次方函数
tf.exp(x,name = None)计算e的次方
tf.log(x,name = None)计算log
tf.maximum(x,y,name = None)返回最大值
tf.minimum(x,y,name = None)返回最小值
tf.cos(x,name = None)三角函数cosine
tf.sin(x,name = None)三角函数sine
tf.tan(x,name = None)三角函数tan
tf.atan(x,name = None)三角函数ctan
tf.sign(x,name = None),该函数用于返回输入参数x的符号。如果x小于0,返回-1,如果等于0,返回0,如果大于0,返回1。
tf.cond(pred,true_fn = None,false_fn = None,strict = False,name = None,fn1 = None,fn2 = None),该函数用于有条件的执行函数,当pred为true时,执行true_fn函数,否则执行false_fn函数。