Skip to main content
. 2026 May 5;26(9):2895. doi: 10.3390/s26092895
Algorithm 1 Two-Stage Self-Supervised Training Pipeline
  Input: Normal training set D={Xi}i=1N; hyperparameters m, β, λr, λd, Ew
  % — Stage 1a: CSD Transformer Pre-training —
 1: for epoch =1 to E1a do
 2:  Construct positive pairs from temporally adjacent CSD matrices (M^t,M^t+1)
 3:  Generate hard negatives by injecting orthogonality noise into P–V coupling blocks
 4:  Update CSD Transformer via Ltriplet=max(0,∥za−zp∥−∥za−zn∥+m)
 5: end for
  % — Stage 1b: Temporal VQ-VAE Pre-training —
 6: for epoch =1 to E1b do ▹ Early stopping, patience = 15
 7:  Update VQ-VAE via LVQ-VAE=LVQ+βLcommit+λrLrecon+λdLdiv
 8: end for
▹ StatFusion receives no gradient in Stage 1
  % — Stage 2: Conditional Joint Fine-tuning —
 9: Load pre-trained CSD Transformer and VQ-VAE weights; randomly initialise fusion, gating, StatFusion
10: for epoch =1 to E2 do
11:  if epoch ≤Ew then ▹ Gating warm-up
12:    w←wbase+wmin ▹ Fixed weights
13:  else
14:    w← gating network output (Equation (22))
15:  end if
16:  Ltotal=w1·∥Zexpected−ZCSD∥22+w2·Dsynergy
17:  Update all parameters end-to-end ▹ Gradients flow to StatFusion via MHCA
18: end for
   Output: Trained model; discard VQ-VAE decoder for inference