gpt4 book ai didi

tensorflow - 如何在TensorFlow中计算CNN的准确性

转载 作者:行者123 更新时间:2023-12-04 13:22:11 27 4
gpt4 key购买 nike

我是TensorFlow的新手。我正在使用自己的数据集进行二进制分类。但是我不知道如何计算精度。谁能帮我做到这一点?

我的分类器有5个卷积层,其后是2个完全连接的层。最终的FC层的输出尺寸为2,我已经使用了该尺寸:

prob = tf.nn.softmax(classification_features, name="output")

最佳答案

只需计算正确预测的百分比即可:

prediction = tf.math.argmax(prob, axis=1)
equality = tf.math.equal(prediction, correct_answer)
accuracy = tf.math.reduce_mean(tf.cast(equality, tf.float32))

关于tensorflow - 如何在TensorFlow中计算CNN的准确性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42607930/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com