Küçük bir dikkat ağının, bir slaytta hangi karoların mutasyonu ele verdiğini öğrenmesini izleyin.
Watch a tiny attention network learn which patches on a slide betray a mutation.
Her yinelenen terim için tek tanım. Sayfada terim, bir paragrafta ilk geçtiği yerde noktalı çizgiyle vurgulanır; üzerine gelin ya da dokunun.
One definition per recurring term. On the page a term is dotted-underlined where it first appears; hover or tap it.
Her olgu, 16 karoya bölünmüş sentetik bir slayttır. Elimizdeki tek etiket slayt düzeyindedir: tümör M sürücü mutasyonunu taşır ya da taşımaz. Hiçbir karo etiketli değildir. Çoklu örnek öğrenme (MIL) kurgusu budur: slayt bir torbadır, karoları örneklerdir ve MIL varsayımı en az bir örnek pozitifse torbanın pozitif olduğunu söyler.
120 slaytın tamamı bir betikle çizilmiştir; bu yüzden her karonun gerçeği bilinir — gerçek bir veri setinin asla vermediği şey tam da budur. 80'i eğitim kümesini oluşturur; 40'ı ağın eğitim sırasında hiç görmediği test kümesi olarak ayrılmıştır. İnceleyiciye almak için herhangi bir slayta tıklayın.
Bir mutant slaytta 16 karodan yalnızca 2–4'ü mutant deseni gösterir: büyümüş çekirdek, berrak sitoplazma ve belirgin çekirdekçik. Diğer karolar sıradan tümör, stroma ya da benzerlerdir. Yabanıl tip slaytlar aynı benzerleri içerir: pleomorfik karolar (büyük çekirdek, solukluk yok) ve dejenere karolar (solukluk var, çekirdek sıradan); her slaytta her birinden bir ila üç tane. Yani hiçbir tek ölçüm sınıfları ayırmaz; ağın bir birleşimi öğrenmesi gerekir ve bunu yalnızca slayt etiketlerinden öğrenmek zorundadır.
Her karo altı ölçüme indirgenir. Pratikte bu adım, 256 piksellik bir karoyu 1024 ya da daha fazla sayıdan oluşan bir gömmeye çeviren dondurulmuş bir temel modeldir; burada her ağırlık okunabilir kalsın diye altı sayı kullanıyoruz.
| # | Ölçüm | Mutant desen | Not |
|---|---|---|---|
| x₁ | Ortalama çekirdek boyutu | yüksek | pleomorfik benzerlerde de yüksek |
| x₂ | Çekirdek yoğunluğu | biraz düşük | stromada çok düşük |
| x₃ | Sitoplazmik solukluk | yüksek | dejenere benzerlerde de yüksek |
| x₄ | Çekirdekçik belirginliği | yüksek | pleomorfik karolarda orta |
| x₅ | Stroma oranı | düşük | mutasyonla ilgisiz |
| x₆ | Hematoksilen yoğunluğu | yok | tümör değil, tarayan laboratuvar belirler |
Every case is one synthetic slide, cut into 16 patches. The only label we have is at slide level: the tumour carries driver mutation M, or it does not. No patch is labelled. That is the multiple-instance setting: the slide is a bag, its patches are instances, and the MIL assumption says a bag is positive when at least one instance is.
All 120 slides are drawn by a script, so the truth is known for every patch, which is exactly what a real dataset never gives you. 80 form the training set; 40 are held out as a test set the network never sees while training. Click any slide to put it under the inspector.
In a mutant slide only 2 to 4 of the 16 patches show the mutant pattern: enlarged nuclei with clear cytoplasm and prominent nucleoli. The other patches are ordinary tumour, stroma, or look-alikes. Wild-type slides contain the same look-alikes: pleomorphic patches (big nuclei, no pallor) and degenerate patches (pallor, ordinary nuclei), one to three of each per slide. So no single measurement separates the classes; the network has to learn a conjunction, and it has to learn it from slide labels alone.
Each patch is reduced to six measurements. In practice this step is a frozen foundation model that turns a 256-pixel tile into an embedding of 1024 or more numbers; here we use six so that every weight stays readable.
| # | Measurement | Mutant pattern | Note |
|---|---|---|---|
| x₁ | Mean nuclear size | high | also high in pleomorphic look-alikes |
| x₂ | Nuclear density | slightly low | stroma is very low |
| x₃ | Cytoplasmic pallor | high | also high in degenerate look-alikes |
| x₄ | Nucleolar prominence | high | moderate in pleomorphic patches |
| x₅ | Stroma fraction | low | irrelevant to the mutation |
| x₆ | Haematoxylin intensity | none | set by the scanning lab, not the tumour |
Her slayt iki laboratuvardan birinde tarandı. B laboratuvarının hematoksileni daha zayıf: daha soluk çekirdekler, daha az kontrast. Bu hem x₆'da hem görüntüde görünür. Varsayılan olarak laboratuvar mutasyondan bağımsızdır. Aşağıdaki tuzak, kestirme öğrenme dersi içindir.
Every slide was scanned at one of two labs. Lab B's haematoxylin is weaker: paler nuclei, less contrast. That shows up in x₆ and in the image. By default the lab is independent of the mutation. The trap below is for the shortcut lesson.
Dolu = eğitim karoları, geldikleri slaytın etiketine göre renkli. İçi boş = gösterildiğinde test karoları. Slaytını incelemek için bir noktaya tıklayın.
Filled = training patches, coloured by the label of the slide they come from. Hollow = test patches when revealed. Click a point to inspect its slide.
Ders noktasıBir mutant slaytın karolarının çoğu yabanıl tip karolardan ayırt edilemez. Her karoya slaytının etiketini verseydiniz çoğunlukla yanlış etiketlerle eğitiyor olurdunuz. Elimizde yalnızca slayt düzeyinde denetim var; önemli olan birkaç karoyu havuzlama adımının bulması gerekir.
Lecture pointMost patches of a mutant slide are indistinguishable from wild-type patches. If you gave every patch its slide's label you would be training on mostly wrong labels. Slide-level supervision is all we have, and the pooling step has to find the few patches that matter.
Ağın üç parçası vardır ve bunlar her modern slayt düzeyi modelin üç parçasıdır. Paylaşımlı kodlayıcı her karonun altı sayısını gizli bir vektöre eşler; aynı ağırlıklar her karoya uygulanır. Bir havuzlama adımı 16 gizli vektörü tek bir slayt vektörüne çevirir. Bir sınıflandırıcı slayt vektörünü P(mutant)'a çevirir. Kayıp fonksiyonuna yalnızca slayt etiketi ulaşır; geri yayılım gradyanı havuzlamadan geçirip her karoya geri iter.
The network has three parts and they are the three parts of every modern slide-level model. A shared encoder maps each patch's six numbers to a hidden vector; the same weights are applied to every patch. A pooling step turns the 16 hidden vectors into one slide vector. A classifier turns the slide vector into P(mutant). Only the slide label reaches the loss, and backpropagation pushes the gradient back through pooling into every patch.
Satırlar gizli birimler, sütunlar altı ölçüm. Mor = pozitif ağırlık, macenta = negatif. Son sütun, birimin logit'e taşıdığı sınıflandırıcı ağırlığı wc.
Rows are hidden units, columns the six measurements. Purple = positive weight, magenta = negative. The last column is the classifier weight wc that unit carries into the logit.
Neye bakmalıTemiz veri setinde eğitimden sonra, önemli birimler boyutu (x₁), solukluğu (x₃) ve çekirdekçiği (x₄) birlikte tartar; boya sütunu (x₆) sıfıra yakın kalır. Laboratuvar karışıklığından sonra x₆'nın büyümesini izleyin.
What to look forAfter training on the clean dataset, the units that matter weight size (x₁), pallor (x₃) and nucleoli (x₄) together and the stain column (x₆) stays near zero. After the lab confound, watch x₆ grow.
Ortalama havuzlama 16 gizli vektörün ortalamasını alır. On altı karodan iki mutant karo slayt vektörünün 2/16'sını, her iki sınıfta aynı görünen sıradan karolar geri kalanını katar. Sinyal, sınıflandırıcı onu görmeden seyrelir: kayıp yüksekte kalır, eğitim doğruluğu takılır. Ama kodlayıcı doğrusal olmadığı için yalnızca mutant birleşimde ateşlenen bir gizli birim öğrenebilir ve o birimin ortalaması slaytları iyi sıralar. Ortalama havuzlama, literatürde de olduğu gibi, güçlü bir temel çizgidir; kusuru emin bir karar verememesidir.
Maksimum havuzlama her gizli boyut için karolar arasındaki en büyük değeri tutar. MIL varsayımının işleç olarak yazılmış hâlidir: slayt, en pozitif karosu kadar pozitiftir. Eğitim kümesine uyar; ama gradyan her boyutta yalnızca bir karoya ulaşır ve tek bir benzer karo yanlış bir kararı taşıyabilir. Üç yöntem içinde test kümesini en kötü sıralayan budur.
Dikkat (Ilse, Tomczak ve Welling, 2018) her karo için karonun kendisinden bir puan öğrenir, puanları softmax ile normalleştirir ve o ağırlıklarla ortalama alır. Yumuşak, öğrenilmiş bir maksimumdur. Her karo gradyan alır, ağırlıklar slayt üzerine dikkat haritası olarak geri çizilebilir ve bu harita yöntemin patolojide kullanılmasının ana nedenidir. CLAM, TransMIL ve slayt düzeyi mutasyon ve MSI tahmincilerinin çoğu bu bloğun çeşitlemeleridir. Bedeli parametre sayısıdır: 80 slaytla dikkat, eğitim kümesini ezberleyebilir. Ağırlık sönümü 0 iken kaybın sıfıra yapıştığını ve test AUROC'unun biraz düştüğünü görün.
Ders noktasıÖnce ortalamayı eğitin ve takılmasına izin verin. Sonra maksimum, sonra dikkat; her biri yeni bir sıfırlamadan. Beklenen (sabit tohum, ağırlık sönümü 0,03, 150–200 devir): ortalama eğitim ≈ %94, test AUROC ≈ 0,95; maksimum eğitim ≈ %90–96, test AUROC ≈ 0,88; dikkat eğitim %93–100 (sönüm altında salınır), test AUROC ≈ 0,97–0,99; ağırlık sönümü 0 ile dikkat eğitim %100, test AUROC ≈ 0,93. Dikkatin kazandırdığı şey harita ve keskin karardır, kendiliğinden daha iyi genelleme değil.
Mean pooling averages all 16 hidden vectors. Two mutant patches in sixteen contribute 2/16 of the slide vector, and the ordinary patches, which look the same in both classes, contribute the rest. The signal is diluted before the classifier ever sees it: the loss stays high and training accuracy stalls. But because the encoder is nonlinear it can learn a hidden unit that fires only on the mutant conjunction, and the mean of that unit ranks slides well. Mean pooling is a strong baseline, here as in the literature; its defect is that it cannot make a confident call.
Max pooling keeps, per hidden dimension, the largest value across patches. It is the MIL assumption written as an operator: the slide is as positive as its most positive patch. It fits the training set, but the gradient reaches only one patch per dimension, and one look-alike patch can carry a wrong call. Of the three it ranks the test set worst.
Attention (Ilse, Tomczak and Welling, 2018) learns a score per patch from the patch itself, normalises the scores with a softmax, and averages with those weights. It is a soft, learned max. Every patch gets gradient, the weights can be drawn back on the slide as an attention map, and that map is the main reason the method is used in pathology. CLAM, TransMIL and most slide-level mutation and MSI predictors are variations on this block. The price is parameters: with 80 slides, attention can memorise the training set. Set weight decay to 0 and watch the loss stick to zero while the test AUROC slips.
Lecture pointTrain mean first and let it stall. Then max, then attention, each from a fresh reset. Expect (fixed seed, weight decay 0.03, 150–200 epochs): mean training ≈ 94%, test AUROC ≈ 0.95; max training ≈ 90–96%, test AUROC ≈ 0.88; attention training 93–100% (it oscillates under decay), test AUROC ≈ 0.97–0.99; attention with weight decay 0 trains to 100% and tests at ≈ 0.93. What attention buys is the map and a sharp call, not better generalisation by itself.
Ağın hiç görmediği kırk slayt; eğitim kümesi hangi yöne eğilmiş olursa olsun, iki laboratuvardan eşit sayıda taranmış. Bir sonrakini sınıflandırmak için N'ye ya da düğmeye basın. Gerçek etiket yalnızca karardan sonra gösterilir; prospektif bir çalışma böyle işler.
Forty slides the network has never seen, scanned at both labs in equal measure, whichever way the training set was tilted. Press N or the button to classify the next one. The truth is revealed only after the call, which is how a prospective study works.
Harita modelin ağırlığını nereye koyduğunu gösterir; bu, mutant desenin nerede olduğuyla aynı şey değildir. Üç şey düzenli olarak ters gider. Dikkat, logit'i aşağı iten bir karoda yüksek olabilir (Kanıt sekmesini açın: ağırlık ve katkı farklı sayılardır). Dikkat, biyolojiyle ilgisi olmayan slayt geneli bir özelliği, örneğin boyayı, paylaşan karolara yayılabilir. Ve dikkat edilmeyen bir karo yokluğun kanıtı değildir: softmax'in dağıtacak yalnızca bir birim ağırlığı vardır. Eğitmen düğmesi açıkken haritayı karo gerçeğiyle karşılaştırabilirsiniz; gerçek bir veri setinde bunu yapamazsınız. Dikkat haritalarının bir patolog tarafından okunup lokalizasyon sonucu olarak değil, sağlamlık denetimi olarak raporlanmasının nedeni budur.
1. adımda laboratuvar karışıklığını açıp yeniden eğitin. Ağın düşük eğitim kaybına giden iki yolu vardır: birkaç karodaki boyut, solukluk ve çekirdekçik birleşimini öğrenmek ya da slaytın her karosunda bulunan ve tek bir ağırlığa mal olan boya yoğunluğunu okumak. Gradyan inişi önce ucuz yolu seçer. Dikkat haritası düzleşir, x₆ ağırlığı büyür, eğitim doğruluğu yüksek kalır ve test AUROC'u rastlantıya doğru iner. Tarayıcı, boyama cihazı, fiksasyon ve kesit kalınlığından kaynaklanan bu tür parti etkileri, yayımlanmış slayt düzeyi modellerin yeni bir merkezde performans kaybetmesinin ana nedenidir ve merkeze göre katmanlı bölme ile boya artırmanın artık standart olmasının gerekçesidir.
Yapıyı koruyun; ölçeği değiştirin. Gerçek bir hat tüm slayt görüntüsünde dokuyu tespit eder, 10×–20×'te 224–512 piksellik on binlerce karoya böler, her karoyu dondurulmuş bir temel modelle gömer ve tam olarak bu dikkat bloğunu dizilemeden alınan slayt düzeyi etiketlerle eğitir. Bölmeler slayta değil hastaya göredir; doğrulama dış bir kohortta yapılır. En çok çalışılan hedefler için bildirilen performans — kolorektal kanserde MSI, akciğer adenokarsinomunda EGFR, glioma IDH, kolorektal ve tiroid tümörlerinde BRAF — hedefe ve kohorta göre kabaca 0,75–0,95 AUROC aralığındadır; ön tarama ve triyaj için yeterli, testin yerini almak için yetersizdir.
Simülasyonun dışarıda bıraktıkları: 20.000 yerine 16 karo; kimsenin okuyamadığı 1024 boyutlu bir gömme yerine altı okunabilir ölçüm; hasta başına tek slayt; dengeli sınıf oranı (çoğu mutasyon nadirdir, bu yüzden kayıp ve metrik özen ister); olasılıkların kalibrasyonu; ve gerçek bir tümörde "mutant desen"in sabit bir karo oranında bulunan keskin bir fenotip değil, istatistiksel bir eğilim olduğu gerçeği.
The map shows where the model placed its weight, which is not the same as where the mutant pattern is. Three things go wrong routinely. Attention can be high on a patch that pushes the logit down (open the Evidence tab: weight and contribution are different numbers). Attention can be spread over patches that share a slide-wide property, like stain, that has nothing to do with biology. And an unattended patch is not evidence of absence: the softmax only has one unit of weight to give away. With the lecturer toggle on, you can compare the map against patch truth; in a real dataset you cannot, which is why attention maps are read by a pathologist and reported as a sanity check, not as a localisation result.
Turn on the lab confound on step 1 and retrain. The network has two routes to a low training loss: learn the conjunction of size, pallor and nucleoli in a few patches, or read the stain intensity, which is on every patch of the slide and costs one weight. Gradient descent takes the cheap route first. The attention map flattens, the x₆ weight grows, training accuracy stays high and test accuracy falls toward chance. Batch effects of this kind, from scanners, stainers, fixation and section thickness, are the main reason published slide-level models lose performance at a new site, and the reason site-stratified splits and stain augmentation are now standard.
Keep the structure; change the scale. A real pipeline detects tissue on the whole-slide image, tiles it into tens of thousands of 224 to 512 pixel patches at 10× to 20×, embeds each patch with a frozen foundation model, and trains exactly this attention block on slide-level labels taken from sequencing. Splits are by patient, not by slide, and validation is on an external cohort. Reported performance for the best studied targets, MSI in colorectal cancer, EGFR in lung adenocarcinoma, IDH in glioma, BRAF in colorectal and thyroid tumours, sits in the AUROC range of roughly 0.75 to 0.95 depending on target and cohort, which is good enough for pre-screening and triage and not good enough to replace the assay.
What the simulation leaves out: 16 patches instead of 20,000; six readable measurements instead of a 1024-dimensional embedding that nobody can read; one slide per patient; a balanced class ratio (most mutations are rare, so the loss and the metric need care); calibration of the probabilities; and the fact that in a real tumour the "mutant pattern" is a statistical tendency, not a crisp phenotype present in a fixed fraction of patches.