tensorflow bias_add应用


https://www.cnblogs.com/lovephysics/p/7222022.html



复制代码
import tensorflow as tf


a=tf.constant([[1,1],[2,2],[3,3]],dtype=tf.float32)
b=tf.constant([1,-1],dtype=tf.float32)
c=tf.constant([1],dtype=tf.float32)


with tf.Session() as sess:
    print('bias_add:')
    print(sess.run(tf.nn.bias_add(a, b)))
    #执行下面语句错误
    #print(sess.run(tf.nn.bias_add(a, c)))


    print('add:')
    print(sess.run(tf.add(a, c)))
复制代码
输出结果:


bias_add:
[[ 2. 0.]
[ 3. 1.]
[ 4. 2.]]
add:
[[ 2. 2.]
[ 3. 3.]
[ 4. 4.]]


 






 

猜你喜欢

转载自blog.csdn.net/zlrai5895/article/details/79460050