0Pricing
Deep Learning Academy · Lesson

Grad-CAM: See What the Model Looks At

Visualize which pixels drive a decision.

Grad-CAM: See What the Model Looks At is a free Deep Learning Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Deep Learning Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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.6

Quick 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. 🎯

Frequently asked questions

Is the “Grad-CAM: See What the Model Looks At” lesson free?

Yes — the full text of “Grad-CAM: See What the Model Looks At” is free to read here on the web, and the Deep Learning Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Deep Learning Academy course, upgrade to CoddyKit PRO.

What will I learn in “Grad-CAM: See What the Model Looks At”?

Visualize which pixels drive a decision. You practise Deep Learning Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Deep Learning Academy?

No prior experience is required. Deep Learning Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Grad-CAM: See What the Model Looks At” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Deep Learning Academy lesson?

Yes. Every Deep Learning Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Precision, Recall, F1 & ROC-AUC
  2. Confusion Matrices & Error Analysis
  3. Grad-CAM: See What the Model Looks At
  4. Calibrate Confidence
← Back to Deep Learning Academy