【发布时间】:2017-12-12 00:27:43
【问题描述】:
我尝试通过利用 tf.metrics 子模块中的函数(例如 tf.metrics.accuracy(y_labels, y_predicted) 和用于精度或召回率的等效项)向我的 CNN 训练代码添加一些额外的测量值。这与他们建议的大多数教程相反:
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
而我的实现将这一行替换为:
accuracy = tf.metrics.accuracy(y_labels, y_predicted)
现在,即使我在 with tf.Session() as sess: 块中执行 sess.run(tf.initialize_all_variables()),尝试使用 tf.metrics.accuracy 函数时仍然收到以下错误:
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value performance/accuracy/count
[[Node: performance/accuracy/count/read = Identity[T=DT_FLOAT, _class=["loc:@performance/accuracy/count"], _device="/job:localhost/replica:0/task:0/cpu:0"](performance/accuracy/count)]]
最值得注意的是,用 accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) 替换 accuracy = tf.metrics.accuracy(y_labels, y_predicted) 行可以解决问题,但是,我想在不手动执行的情况下实现其他指标,例如精度、召回率等。
【问题讨论】:
标签: python tensorflow neural-network conv-neural-network tensorboard