UFR-Fing / scripts /run_train_v22.sh
anbinh39's picture
Add files using upload-large-folder tool
cfc7a54 verified
Raw
History Blame Contribute Delete
3.36 kB
#!/usr/bin/env bash
# v22 training β€” First correct run: full prototypes + random batching + single GPU.
#
# Root cause analysis β€” why v15–v21 all failed:
#
# BUG 1 β€” CrossSensorBatchSampler default k_cross=16:
# k_cross=16 forces 16 guaranteed cross-sensor pairs per batch.
# With full prototypes (nearly-constant L_mat targets for SD302), backbone
# over-optimises sensor invariance β†’ loses quality discrimination β†’
# Pearson collapses (~0.09 in v21). Fix: --k-cross 0 (random batching).
#
# BUG 2 β€” proto-max-batches default=150:
# Only 45% of dataset used for prototypes β†’ 2–3 partial sensor prototypes
# per SD302 identity β†’ cosine target is sensor-biased, not quality-correlated
# β†’ no per-image quality gradient β†’ score collapse in v15–v19.
# Fix: --proto-max-batches 0 (full dataset).
#
# BUG 3 β€” DataParallel (––gpus 0,1) 4.3Γ— slower for TinyViT-5M:
# Fix: --gpus 0 (single GPU).
#
# BUG 4 β€” Redundant teacher double-pass at startup:
# Fix: build_prototypes_from_cache() β€” O(N) CPU, no second teacher forward.
#
cd /home/aiserver/works/fingerprint
nohup bash sifq/scripts/run_train_v22.sh > sifq/logs/train_v22.log 2>&1 &
echo "PID: $!"
tail -f sifq/logs/train_v22.log# v22 design goals (per research design Β§4–7):
# Quality-discriminative : q_std β‰₯ 18 (model ranks fingerprints by utility)
# Sensor-invariant : pair loss β†’ 0 (L_sens equilibrium), adv β†’ rand_ce
# Concept-grounded : all Track 4 target concepts negative Spearman ρ
# Training speed : ~220s/epoch (single GPU, no DataParallel overhead)
#
# Note on L_sens / pair loss:
# v22 includes SD302-A (8 diverse roll sensors per finger) which creates genuine
# cross-sensor quality variation in L_mat targets. L_pair starts high (~12 at
# S2 onset) and decreases as L_sens equilibrium is found. This is expected
# with a richer, more diverse dataset β€” it is NOT a training failure.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
export PATH="/home/aiserver/miniconda3/bin:$PATH"
VERSION="v22"
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 96 \
--image-size 224 \
--lr 1e-4 \
--spread-mode uniform \
--spread-weight 3.0 \
--concept-deg-gamma 0.5 \
--sd302-concept-weight 0.0 \
--deg-every-n-steps 2 \
--no-mat-stats \
--proto-max-batches 0 \
--k-cross 0 \
--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