笔记 - 模型评估:准确率评估

laebl one-hot编码的准确率计算

import tensorflow as tf

y = tf.constant([[0, 0, 1], 
				[1, 0, 0]], dtype=tf.float32)
y_pred = tf.random_uniform(shape=(2, 3))


accuracy = tf.reduce_mean(tf.cast(tf.equal(tf.argmax(y, 1), tf.argmax(y_pred, 1)), dtype=tf.float32))
with tf.Session() as sess:
    print(accuracy.eval())

猜你喜欢

转载自blog.csdn.net/chen_holy/article/details/91411409