import tensorflow as tf
y = tf.constant([[0,0,1],[0,1,0],[0,0,1]])
pred = tf.constant([[0.2, 0.3 , 0.5],[0.2 , 0.2 , 0.6],[0.3 , 0.3 , 0.4]])
pred2 = tf.equal(tf.argmax(pred, 1), 2)
#pred2_sum = tf.reduce_sum(tf.cast(pred0,tf.int32))
real2 = tf.equal(tf.argmax(y, 1), 2)
#accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
with tf.Session() as sess:
result1 = sess.run(pred2)
result2 = sess.run(real2)
print result1,result2
pred2_is_true2 = 0
for index,value in enumerate(result1):
if value:
if result2[index]: pred2_is_true2 += 1
else: pass
print pred2_is_true2/float(sum(result1))
Tensorflow 讓張量流1
最后編輯于 :
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
推薦閱讀更多精彩內(nèi)容
- *本文內(nèi)容均來自易仁永澄老師分享內(nèi)容 我很喜歡這張圖,因為在這張圖里面包含著兩層意思:一種是一堆肉和一團混亂的情緒...