且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Tensorflow 中添加整个训练/测试数据集的准确性摘要

更新时间:2023-12-02 18:41:40

定义一个接受占位符的 tf.scalar_summary:

Define a tf.scalar_summary that accepts a placeholder:

accuracy_value_ = tf.placeholder(tf.float32, shape=())
accuracy_summary = tf.scalar_summary('accuracy', accuracy_value_)

然后计算整个数据集的准确率(定义一个例程,计算数据集中每批的准确率并提取平均值)并将其保存到python变量中,我们称之为va.

Then calculate the accuracy for the whole dataset (define a routine that calculates the accuracy for every batch in the dataset and extract the mean value) and save it into a python variable, let's call it va.

获得va 的值后,只需运行accuracy_summary 操作,输入accuracy_value_ 占位符:

Once you have the value of va, just run the accuracy_summary op, feeding the accuracy_value_ placeholder:

sess.run(accuracy_summary, feed_dict={accuracy_value_: va})