Skip to main content
. 2026 Jun 13;26(12):3782. doi: 10.3390/s26123782
Algorithm 1 ViT Variant Training for Radar Error Correction
  •   1:

    Input: Radar measurements {ri}i=1N, AIS ground-truth positions {ai}i=1N

  •   2:

    Output: Trained model parameters Θ*

  •   3:

    Preprocessing:

  •   4:

     Convert AIS (ϕi,λi) to local Cartesian (xi,yi) via Equations (4) and (5)

  •   5:

     Temporal synchronisation: interpolate AIS positions to radar timestamps via Equations (6) and (7)

  •   6:

     Compute target errors: Δri=ri−riAIS, Δθi=θi−θiAIS via Equation (1)

  •   7:

     Construct 12-D feature vectors xi∈R12 via Section 2.3.3

  •   8:

     Vessel-level split: Dtrain∪Dval∪Dtest (70:15:15)

  •   9:

    Initialise: Θ={E,Epos,zcls,θenc,Wr,Wθ,br,bθ,sr,sθ} via Xavier

  • 10:

    Hyperparameters: B=512, η0=10−3, ηmin=10−6, λ=10−4, P=25

  • 11:

    t←0, patience_counter←0, Lbest←∞

  • 12:

    while t<150 and patience_counter<P do

  • 13:

     Sample mini-batch B⊂Dtrain, |B|=B

  • 14:

     for each x∈B do

  • 15:

      Patch embedding: z0=[zcls;E·x(1)+Epos(1);…;E·x(4)+Epos(4)]   (Equation (9))

  • 16:

      Transformer: zN=TransformerEncoder(z0)      (Equations (10) and (11))

  • 17:

      Predict: Δr^=Wr·zN[CLS]+br, Δθ^=Wθ·zN[CLS]+bθ  (Equations ((12) and (13)))

  • 18:

     end for

  • 19:

     Ltotal←1B∑(wr|Δr−Δr^| + wθ|Δθ−Δθ^|)+λ∥Θ∥22   (Equation (18))

  • 20:

     wr=softplus(−sr), wθ=softplus(−sθ)             (Equation (19))

  • 21:

     Θ←Θ−ηt·∇ΘLtotal (AdamW, clipped at ∥∇∥∞=1.0)

  • 22:

     ηt←ηmin+12(η0−ηmin)(1+cos(t150π))          (cosine annealing)

  • 23:

     if Lval<Lbest then

  • 24:

      Θ*←Θ, Lbest←Lval, patience_counter←0

  • 25:

     else

  • 26:

      patience_counter←patience_counter+1

  • 27:

     end if

  • 28:

     t←t+1

  • 29:

    end while