แนวคิด
ใช้ไลบรารี matplotlib และเมธอด imshow เพื่อแสดงภาพผลลัพธ์จากโมเดล
แนวคิด Transfer Learning สำหรับ Image Classification: โมเดลที่เทรนบนข้อมูลใหญ่และทั่วไป จะทำหน้าที่เป็นโมเดลทั่วไปสำหรับโลกภาพได้เรียนรู้ feature maps แล้ว ไม่ต้องเริ่มเทรนโมเดลใหญ่จากศูนย์
TensorFlow Hub มีโมเดล pre-trained ให้ใช้ fine-tune เรียนรู้การใช้โมเดลจาก TF Hub กับ tf.keras ทำ Transfer Learning สำหรับคลาสภาพที่กำหนดเอง ใช้ pretrained classifier ทำนายภาพได้เลยโดยไม่ต้องเทรน
รันบน Google Colab ที่มี GPU ฟรี
ตัวอย่างโค้ด
print("The results are plotted")
plt.figure(figsize=(10,9))
plt.subplots_adjust(hspace=0.5)
for n in range(30):
plt.subplot(6,5,n+1)
plt.imshow(image_batch[n])
plt.title(predicted_label_batch[n].title())
plt.axis('off')
_ = plt.suptitle("Model predictions")
Credit: TensorFlow Tutorials
ผลลัพธ์


คำอธิบาย
- ผลลัพธ์ถูกพลอทแสดงบนคอนโซล