1
import tensorflow as tf
a = tf.constant([[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]])
b = tf.constant([[5,4,3,2,1],[1,2,3,4,5],[1,2,3,4,5]])
product =tf.mul(a,b)
product_sum =tf.reduce_sum(tf.mul(a,b))
with tf.Session() as sess:
print product.eval()
print product_sum.eval()
[[ 5 8 9 8 5]
[ 1 4 9 16 25]
[ 1 4 9 16 25]]
145
但它不是我想要的答案。
欲得到答案
[5 + 8 + 9 + 8 + 5,1 + 4 + 9 + 16 + 25,1 + 4 + 9 + 16 + 25] = [35, 55,55]
'product_sum = tf.reduce_sum (產品,軸= 1)' – xxi
是的,你是對的,太棒了!謝謝! –