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

การตรวจสอบการทำนาย (Checking Predictions) ด้วย TensorFlow และ Python


แนวคิด

ใช้เมธอด predict ของโมเดล และ argmax จาก NumPy เพื่อหาคลาสที่มีความน่าจะเป็นสูงสุด

แนวคิด Transfer Learning และ TensorFlow Hub เหมือนบทก่อน รันบน Google Colab

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

print("The predictions are checked")
predicted_batch = model.predict(image_batch)
predicted_id = np.argmax(predicted_batch, axis=-1)
predicted_label_batch = class_names[predicted_id]

Credit: TensorFlow Tutorials

ผลลัพธ์

The predictions are checked

คำอธิบาย

  • สามารถพลอทผลลัพธ์ซ้ำได้โดยใช้ ordered list ของ class names
  • ทำได้โดยการดึง class names ที่เรียงลำดับแล้วมาใช้