1. 程式人生 > >tensorflow bias_add應用

tensorflow bias_add應用

log ssi run span 分享 ima spa col oat

技術分享

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.]]

技術分享

tensorflow bias_add應用