UFR-Fing / scripts /run_train_v29.sh
anbinh39's picture
Add files using upload-large-folder tool
cfc7a54 verified
Raw
History Blame Contribute Delete
3.53 kB
#!/usr/bin/env bash
# v29 training β€” T41 concept map + ortho-weight 3.0 + concept-spread-weight 1.0
#
# Goal: Fix concept grounding failures observed in v28 eval:
# - continuity collapsed (mean=0.068, std=0.076) due to JPEG+dry_skin gradient conflict
# - noise_level inverted (Spearman +0.56) due to Gaussian noise boosting texture energy
# - orient_coh, contrast_uni saturated (~0.94, ~0.85) due to weak L_ortho
# - clarity flat (std=0.043) due to insufficient training signal
#
# T41 concept map changes vs T39:
# jpeg: [2, 1] β†’ [1] remove continuity β€” JPEG artifacts go wrong direction
# dry_skin: [4, 2, 0] β†’ [4, 0] remove continuity β€” dry_skin gradient was wrong direction
# noise: [3] β†’ [1, 3] add clarity co-target β€” noise blurs ridges (anchor signal)
#
# New hyperparameters:
# --ortho-weight 3.0 : 3Γ— stronger concept de-correlation (vs 1.0 in v28)
# --concept-spread-weight 1.0: penalise concepts with batch std < 0.20
# directly targets: orient_coh saturation, continuity collapse
#
# Inherited from v28 (validated):
# --no-mat : no MDGT teacher (KS=0.1346 vs v24=0.1263 β€” acceptable)
# --spread-weight 4.0
# --concept-deg-gamma 2.0
# --k-cross 0
#
# Expected dynamics:
# S1 (ep 0-9): l_cspread decreases from ~0.1 toward 0; concepts spread to std β‰₯ 0.20
# S2+ (ep 20+): orient_coh, contrast_uni no longer saturated; continuity varies with blur
# noise_level: co-target with clarity should reduce inversion
# Target: KS ≀ 0.15, Pearson β‰₯ 0.75, concept stds all β‰₯ 0.15 at inference
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
export PATH="/home/aiserver/miniconda3/bin:$PATH"
VERSION="v29"
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" \
--no-mat \
--epochs 60 \
--batch-size 96 \
--image-size 224 \
--lr 1e-4 \
--spread-mode uniform \
--spread-weight 4.0 \
--ortho-weight 3.0 \
--concept-spread-weight 1.0 \
--concept-deg-gamma 2.0 \
--sd302-concept-weight 0.0 \
--deg-every-n-steps 2 \
--k-cross 0 \
--max-train-samples -1 \
--num-workers 8 \
--gpus 0 \
--save-dir "${SAVE_DIR}" \
2>&1 | tee "${LOG_FILE}"
echo "[auto-eval] Training done. Starting eval ${VERSION}..."
bash "${EVAL_SCRIPT}" >> "${LOG_FILE}" 2>&1
# ── Compact epoch log ──────────────────────────────────────────────────────
# Strip tqdm noise β€” keep only Epoch summary lines and header info.
EPOCH_LOG="${REPO_ROOT}/sifq/logs/train_${VERSION}_epochs.log"
{
grep -E "^(Device:|SD302|FVC|PolyU|Excluded|AMP|Sensor|Stage|Pre-cach|Teacher)" "${LOG_FILE}" | head -10
echo "---"
grep "^Epoch" "${LOG_FILE}"
} > "${EPOCH_LOG}" 2>/dev/null || true
echo "[train_${VERSION}] Compact epoch log β†’ ${EPOCH_LOG}"