import tensorflow as tf b = tf.fill([2, 2], 2.) a = tf.ones([2, 2])
a+b
a-b
a*b
a/b
b // a
b % a
tf.math.log(a) # 只有以e为底的log
tf.exp(a)
tf.math.log(8.)/tf.math.log(2.) # 以2为底
tf.math.log(100.)/tf.math.log(10.) # 以10为底
tf.pow(b, 3)
b**3
tf.sqrt(b)
[email protected]
tf.matmul(a, b)
a = tf.ones([4, 2, 3]) # 4作为batch处理 b = tf.fill([4, 3, 5], 2.) # 4作为batch处理
[email protected]
tf.matmul(a, b)
bb = tf.broadcast_to(b, [4, 3, 5]) [email protected]
x = tf.ones([4, 2]) W = tf.ones([2, 1]) b = tf.constant(0.1) # 自动broadcast为[4,1] [email protected] + b
out = [email protected] + b tf.nn.relu(out)
原文地址:https://www.cnblogs.com/tszr/p/12124045.html
时间: 2024-10-09 19:33:28