Research question
An earlier project found Hadamard fusion beating attention-based fusion on HAM10000. But that result came from a single loss function, a single augmentation scheme, and a single train/test split held fixed throughout — so it was impossible to tell whether Hadamard's advantage was a genuine property of the fusion mechanism, or just an artifact of that particular pipeline. This project set out to answer that, by rebuilding the pipeline and varying one factor at a time across six experimental groups, instead of changing everything at once.
What I built
A configurable Swin-Tiny pipeline with lesion-grouped splitting (no lesion appears in more than one of train/validation/test), five loss functions, four independently toggleable preprocessing/augmentation components, 5-fold cross-validation, 8-transform test-time augmentation, three fusion strategies, and an external evaluation protocol against ISIC 2019 — a second dataset the model never trains on.
Each experimental group holds everything fixed except the one factor under study, with later groups building on whichever configuration won in the earlier ones.
Findings, by experiment
1. Loss function
Five losses were compared under identical conditions on raw images. Logit-Adjusted Cross-Entropy (LA-CE) got the highest balanced accuracy (74.94%), but also the worst calibration of the five. Confusion-Frequency Reweighted CE — a reweighting scheme designed for this project — won on macro-F1 and calibration (ECE 0.0392) instead. The two never agreed: accuracy and calibration pulled in opposite directions at the loss level.
2–3. Component ablation under both losses
MixUp, DullRazor hair removal, CutMix, and segmentation-guided cropping were each added individually under both losses. The same component behaved differently depending on the loss underneath it: MixUp nearly preserved balanced accuracy under LA-CE while cutting calibration error by 57%, but reduced balanced accuracy by 3.8 points under CFR-CE. Segmentation-guided cropping had the worst calibration under LA-CE and the best under CFR-CE. No preprocessing choice was universally good — its effect depended entirely on the loss it was paired with.
4. Cross-validation and isolated TTA
Across 5 lesion-grouped folds, balanced accuracy ranged from 72.5% to 76.7% (mean 74.6%) — and the original single-split result sat slightly above that mean, meaning the first reported number was somewhat favorable rather than representative.
Test-time augmentation gave a small, consistent accuracy gain and a clearer calibration improvement across every fold.
5. External validation on ISIC 2019
This is the headline result: balanced accuracy fell from 74.7% internally to 47.8% on the external dataset — a 27-point drop — while calibration error nearly tripled.
Melanoma recall dropped sharply (more false negatives), while vascular lesion and dermatofibroma recall held up but came with very low precision (over-prediction instead). Strong internal numbers did not transfer.
6. Fusion strategy, revisited
Internally, the original finding reproduced exactly: Hadamard outperformed Attention, which outperformed Concatenation, on balanced accuracy and macro-F1 — now under a completely different backbone, loss, and augmentation scheme. Externally, the ranking flipped: Concatenation led on balanced accuracy, while Hadamard remained best on calibration. No single fusion strategy won on every axis.
| Evaluation | Balanced accuracy | Macro-F1 | ECE |
|---|---|---|---|
| Internal (HAM10000, 5-fold mean) | 74.71% | 0.6618 | 0.0389 |
| External (ISIC 2019) | 47.84% | 0.3793 | 0.1256 |
Loss function, not fusion strategy, is what first resolves catastrophic minority-class failure. LA-CE alone, with no metadata at all, already achieves non-trivial recall on the rarest classes. Fusion only refines a baseline that already works; it doesn't create minority-class performance where none existed. No single intervention — loss, preprocessing, TTA, or fusion — simultaneously optimized balanced accuracy, calibration, and generalization to a new dataset. Each one traded off against the others.
Limitations
Cross-validation and external validation were only run for LA-CE-based configurations, so it's unknown whether the other losses or components would be equally robust. ISIC 2019 evaluation used a harmonized 7-class subset, excluding two classes with no HAM10000 equivalent. Each fusion strategy was evaluated with a single trained checkpoint, not across folds or seeds, so the reversed external ranking hasn't been stress-tested for its own variance.