Grad-CAM: ดูว่าโมเดลมองอะไร
แสดงภาพว่าพิกเซลใดมีผลต่อการตัดสินใจ
Grad-CAM: ดูว่าโมเดลมองอะไร เป็นบทเรียน Deep Learning Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Deep Learning Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Open the Black Box
A CNN can be right for the wrong reason. Grad-CAM reveals which pixels actually drove a prediction, so you can trust or question it.
Heatmaps Over the Image
Grad-CAM paints a heatmap on top of the input. Warm regions are where the model focused; cool regions it ignored. 🔥
Gradients Carry Importance
It traces the gradient of the chosen class score back to a convolutional layer, measuring how much each feature map mattered.
Pick a Late Conv Layer
The best maps come from the last convolutional layer, where features are rich yet still spatial enough to localize.
Weight the Feature Maps
Average the gradients to get a weight per feature map, then combine the maps with those weights into one coarse map.
Keep Only the Positive
A ReLU over the combined map keeps regions that push the class up, discarding pixels that argue against it.
cam = torch.relu((weights * activations).sum(dim=0))Upsample to Pixel Size
The map is small, so you upsample it to the image resolution before overlaying it for a clear visual.
Catch Shortcut Learning
If the heatmap lights up the background instead of the object, your model learned a shortcut, not the real signal.
Debug Misclassifications
Run Grad-CAM on wrong predictions to see what misled the model. The focus region often explains the error instantly.
Build Stakeholder Trust
Clear visual evidence of where a model looks makes it far easier to explain and defend in real deployments.
A Window, Not a Proof
Grad-CAM is an approximate visualization, not exact math. Treat it as a strong hint, then confirm with other checks. 🪟
overlay = heatmap * 0.4 + image * 0.6Quick Check
Think about why Grad-CAM is most useful when read alongside model predictions.
Recap
Use Grad-CAM to turn gradients into a heatmap over the image, exposing what drove a prediction and catching shortcut learning. 🎯
คำถามที่พบบ่อย
บทเรียน “Grad-CAM: ดูว่าโมเดลมองอะไร” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “Grad-CAM: ดูว่าโมเดลมองอะไร” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Deep Learning Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “Grad-CAM: ดูว่าโมเดลมองอะไร”
แสดงภาพว่าพิกเซลใดมีผลต่อการตัดสินใจ คุณปฏิบัติ Deep Learning Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Deep Learning Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Deep Learning Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “Grad-CAM: ดูว่าโมเดลมองอะไร” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Deep Learning Academy นี้ได้ไหม
ได้ บทเรียน Deep Learning Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- Precision, Recall, F1 และ ROC-AUC
- เมทริกซ์ความสับสนและการวิเคราะห์ข้อผิดพลาด
- Grad-CAM: ดูว่าโมเดลมองอะไร
- ปรับเทียบความมั่นใจ