Notebook · No. 1
Where the model looked
On attention, explanation, and the page you are reading.
Most of my papers end the same way: with a heatmap. A brain MRI, an eye fundus, a patch of skin, and on top of it a smear of warm colour saying this is where the model was looking. For a while I treated that picture as decoration for the results table. I don’t anymore. I think it is the most important figure in the paper, and also the one most easily misread.
Right, for the wrong reason
A classifier can be accurate and still be wrong in a way that matters. If a tumor model learns the scanner’s watermark, or the edge of the skull, or the way one hospital crops its images, it can score well on a test set drawn from the same place and fail quietly everywhere else. In a clinic, that is not a small bug. It is a model that is right for reasons nobody would sign off on.
That worry shapes most of what we build at Arché. T3SSLNet leans on self-supervised learning so the network learns what brain MRI looks like before it ever sees a label, which makes it harder to latch onto a shortcut in a small labelled set. Hi-TGNet goes further and guides classification through the tumor itself, so the explanation is part of the structure rather than something painted on afterwards. KbFL-XAI asks the same question under federated learning, where the data never leaves the hospital and you cannot simply go and look at it.
What, where, and whether
The clearest way I have found to say this comes from how we lay out the SULCI tumor pipeline. Three outputs, each answering a different question:
- WhatClassification says which tumor it is: glioma, meningioma or pituitary, with a probability.
- WhereSegmentation draws the lesion: whole tumor, core, enhancing region.
- WhetherGradCAM++ shows where the classifier was looking, and we check it against the segmentation. Did it look somewhere plausible?
The third one is the quiet one. It doesn’t change the answer; it tells you whether to trust it. When attention and anatomy agree, the prediction has earned a little credibility. When they disagree, the model has told you something useful about itself, and that is worth more than one more decimal of accuracy.
Attention is a budget
Inside a network, attention is less mysterious than the word suggests. Every input gets a score. The scores go through a softmax, which turns them into weights that are all positive and add up to exactly one. That last property is the whole idea: attention is a fixed budget, and giving more to one thing means giving less to everything else.
A temperature controls how greedy the spending is. Low temperature: almost everything goes to the best-scoring input. High temperature: the budget spreads out evenly and nothing stands out. Try it.
softmax(−distance / T); they always sum to 1.This page does it too
If you opened this from my portfolio, you have already seen that figure running. The little list on the left of the home page, labelled attention, is exactly this: a softmax over the page’s sections. There is a reading line about a third of the way down the window. Each section is scored by how far it is from that line, divided by a temperature of 0.16, and the weights decide how much ink each section gets. The one you are reading is full black; the rest settle back a little.
const scores = sections.map(s => -(distance(s) / innerHeight) / TEMP);
const w = softmax(scores); // positive, sums to 1
section.style.setProperty('--w', w / max(w));
It is a small joke, but a sincere one. A portfolio is a claim about where someone’s attention goes. I wanted mine to show its work the same way I ask my models to: here is what I’m focused on, here is the arithmetic, you can watch it change.
What a heatmap can’t tell you
I want to be careful here, because explanation is easy to oversell. A saliency map is not proof that a model reasoned correctly. It is a picture of what one method says mattered, and different methods can disagree on the same image. A model can look in the right place and still be wrong; it can look somewhere odd and still be right for a reason we haven’t understood yet.
So I treat these maps the way I would treat a colleague’s explanation: as evidence, not a verdict. They are most useful when they are checked against something independent, like the segmentation in SULCI, and most dangerous when they are the only thing standing between a confident number and a patient.
That is the habit I am trying to build, in models and in myself: say what you think, show where you were looking, and leave the reader able to check.
Nasif