Skip to main content
. 2026 Oct 16;16(20):3368. doi: 10.3390/diagnostics16203368
Algorithm 1: Source-Only Group-Aware Multimodal Training
Input:
  HAM10000 source domain D1
  Derm7pt source domain D2
  Harmonized class set Y
  Model parameters Θ
   E
Output:
    Source-validated model Θ*
Method:
1: Harmonize diagnostic labels and metadata across D1 and D2
2: Construct patient-level train, validation, calibration, threshold-fitting, and internal-test partitions
3: Initialize model parameters Θ
4: for epoch = 1 to E do
5: Construct domain-balanced and group-aware mini-batches
6: for each mini-batch B do
7: Extract multi-scale visual features
8: Generate transformer contextual representation zv
9: Encode metadata and availability indicators zm
10: Compute gated multimodal representation z
11: Compute class probabilities and focal loss Lcls
12: Compute the mean focal loss Rg for each sufficiently represented supported group.
13: Compute the smooth worst-group robustness term Lgroup with τ = 0.10.
14: Compute Ltrain = Lcls + 0.10Lgroup.
15: Update model parameters using AdamW with weight decay 1 × 10−4.
16: end for
17: Evaluate macro-F1, worst-group F1, and validation loss
18: Apply early stopping using source validation only
19: end for
20: Return the best source-validated model Θ*