Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีใช้ TensorFlow ประเมินโมเดลทั้งสองบน Test Data ด้วย Python


TensorFlow เฟรมเวิร์ก ML จาก Google Open Source ใช้กับ Python อัลกอริทึม Deep Learning งานวิจัยและ Production

ติดตั้ง tensorflow บน Windows:

pip install tensorflow

Tensor โครงสร้างข้อมูลใน TensorFlow (Data Flow Graph) เป็นอาร์เรย์หลายมิติ/ลิสต์

ใช้ Google Colab รันโค้ด (Python บนเบราว์เซอร์ ฟรี GPU บน Jupyter Notebook)

ตัวอย่างโค้ด

print("The model is being evaluated")
binary_loss, binary_accuracy = binary_model.evaluate(binary_test_ds)
int_loss, int_accuracy = int_model.evaluate(int_test_ds)
print("The accuracy of Binary model is: {:2.2%}".format(binary_accuracy))
print("The accuracy of Int model is: {:2.2%}".format(int_accuracy))

Credit: TensorFlow Tutorials

ผลลัพธ์

The model is being evaluated
250/250 [==============================] - 3s 12ms/step - loss: 0.5265 - accuracy: 0.8110
250/250 [==============================] - 4s 14ms/step - loss: 0.5394 - accuracy: 0.8014
The accuracy of Binary model is: 81.10%
The accuracy of Int model is: 80.14%

คำอธิบาย

  • ประเมิน Loss และ Accuracy ของโมเดล Binary และ Int Vectorized ทั้งคู่

  • แสดงผลบน Console