ฉันพยายามเพิ่มการวัดเพิ่มเติมให้กับโค้ดการฝึกอบรมของฉันสำหรับ CNN โดยใช้ฟังก์ชันจากโมดูลย่อย tf.metrics
เช่น tf.metrics.accuracy(y_labels, y_predicted)
และค่าที่เทียบเท่าเพื่อความแม่นยำหรือการเรียกคืน สิ่งนี้ทำตรงกันข้ามกับบทช่วยสอนส่วนใหญ่ที่พวกเขาแนะนำสิ่งที่ซับซ้อน:
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
ในขณะที่การใช้งานของฉันแทนที่บรรทัดนี้ด้วย:
accuracy = tf.metrics.accuracy(y_labels, y_predicted)
ตอนนี้ แม้ว่าฉันจะทำ sess.run(tf.initialize_all_variables())
ภายในบล็อก with tf.Session() as sess:
ของฉัน แต่ฉันยังคงได้รับข้อผิดพลาดต่อไปนี้เมื่อพยายามใช้ฟังก์ชัน 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.metrics.accuracy(y_labels, y_predicted)
ด้วย accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
จะช่วยแก้ไขปัญหาได้ อย่างไรก็ตาม ฉันต้องการใช้หน่วยวัดอื่นๆ เช่น ความแม่นยำ การเรียกคืน ฯลฯ โดยไม่ต้องทำด้วยมือ