UFR-Fing / scripts /run_train_v18.sh
anbinh39's picture
Add files using upload-large-folder tool
cfc7a54 verified
Raw
History Blame Contribute Delete
3.82 kB
#!/usr/bin/env bash
# v18 training β€” T33: revert to v14 loss design + include SD302-A.
#
# Root cause analysis (v17 failure):
#
# Score collapse persists despite T32 fix: all SD302 images β†’ ~52.7, q_std=0.60.
# Training q_std=16.59 looks healthy but driven by FVC only (same pattern as v15/v16).
#
# Deeper root cause (T33):
# T32 removed explicit L_mat vs L_pair conflict (SD302 gets raw cosine fallback),
# but FVC still gets tanh-normalised targets (high variation) while SD302 gets
# constant raw cosine targets. Model learns to distinguish "FVC mode" (variable)
# from "SD302 mode" (constant) β€” dataset shortcut. At inference (SD302 only): collapse.
#
# Additional factors in v15–v17 that didn't exist in v14 (which worked):
# - W_SPREAD 2.0 β†’ 4.0 (stronger spread pressure amplifies FVC/SD302 asymmetry)
# - concept_deg_gamma 0.5/1.0 β†’ 2.0 (stronger concept loss may destabilise SD302 features)
# - sd302_concept_weight 0 β†’ 1.0 (T30b concept deg on SD302 adds noise to SD302 features)
# - deg-every-n-steps 4 β†’ 2 (more frequent deg steps = more FVC-specific gradients)
#
# v18 fix (T33): revert all v15–v17 additions, add SD302-A as new data
#
# T33a β€” --no-mat-stats: Disable per-identity cosine stats entirely.
# ALL identities (FVC + SD302) use raw cosine as L_mat target (v14 behaviour).
# Eliminates FVC/SD302 quality signal asymmetry. Model must treat both datasets
# similarly β€” SD302 cannot shortcut to constant output.
#
# T33b β€” W_SPREAD = 2.0: Revert from 4.0. Lower spread pressure β†’ backbone retains
# more discriminative features for SD302. v14 used ~2.0.
#
# T33c β€” concept_deg_gamma = 0.5: Revert from 2.0 to v14 default.
#
# T33d β€” sd302_concept_weight = 0.0: Disable SD302 concept degradation (default, v14).
#
# T33e β€” deg-every-n-steps = 4: Revert to original (v14). Fewer FVC-only deg steps.
#
# NEW vs v14 β€” SD302-A: Include dataset/302a/images/challengers (13,630 images, sensors A-H).
# More cross-sensor pairs for L_sens. More GRL training signal. Better coverage.
#
# Expected improvements vs v14:
# - Score spread: q_std > 10 at inference (like v14 ~15)
# - KS: ~0.26 (v14 baseline), potentially better with 8 new SD302-A sensors
# - Pearson: ~0.29 (v14 baseline)
# - More sensor-type coverage (8 SD302-A sensors vs 4 SD302-B + 4 SD302-D in v14)
#
# Train from scratch, 60 epochs, LR=1e-4 cosine.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
export PATH="/home/aiserver/miniconda3/bin:$PATH"
VERSION="v18"
SAVE_DIR="${REPO_ROOT}/sifq/checkpoints/${VERSION}"
LOG_FILE="${REPO_ROOT}/sifq/logs/train_${VERSION}.log"
EVAL_SCRIPT="${REPO_ROOT}/sifq/scripts/run_eval_${VERSION}.sh"
mkdir -p "${REPO_ROOT}/sifq/logs"
python "${REPO_ROOT}/sifq/scripts/train_sifq.py" \
--root-302a "${REPO_ROOT}/dataset/302a/images/challengers" \
--root-302b "${REPO_ROOT}/dataset/302b/images/baseline" \
--root-302d "${REPO_ROOT}/dataset/nist_302d/images/auxiliary" \
--root-fvc2002 "${REPO_ROOT}/dataset/FVC_Dataset/FVC2002" \
--root-fvc2004 "${REPO_ROOT}/dataset/FVC_Dataset/FVC2004" \
--root-polyu "${REPO_ROOT}/dataset/PolyU" \
--exclude-sensor "R_1000_slap,R_500_slap,S_500_slap" \
--mdgt-checkpoint "${REPO_ROOT}/pad/TRAM-downstream/checkpoint/checkpoints_dinov2_tram/best_eer.pt" \
--epochs 60 \
--batch-size 128 \
--image-size 224 \
--lr 1e-4 \
--spread-mode uniform \
--spread-weight 2.0 \
--concept-deg-gamma 0.5 \
--sd302-concept-weight 0.0 \
--deg-every-n-steps 4 \
--no-mat-stats \
--max-train-samples -1 \
--num-workers 8 \
--gpus 0 \
--save-dir "${SAVE_DIR}"
echo "[auto-eval] Training done. Starting eval ${VERSION}..."
bash "${EVAL_SCRIPT}" >> "${LOG_FILE}" 2>&1