File size: 2,758 Bytes
cfc7a54 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #!/usr/bin/env bash
# v27 training — SpatialConceptHead: ConceptHead now operates on 14×14 spatial
# token map [B, 196, 320] instead of globally-pooled vector [B, 320].
#
# Architecture change (relative to v26):
# ConceptHead (legacy): Linear(320→256)→LN→GELU→Linear(256→6)→Sigmoid
# - input: [B, 320] globally-pooled backbone output
# - loses spatial information entirely
# SpatialConceptHead (v27+):
# Shared trunk : Linear(320→128)→LN→GELU → [B, 196, 128]
# Per-concept : 6 × Linear(128→1) → mean over 196 → [B, 6]
# Activation : Sigmoid → (0, 1)
# - input: [B, 196, 320] backbone.forward_spatial() output
# - each concept attends to different spatial regions
# - separate proj weights per concept → reduced entanglement
#
# Why this matters:
# orientation_coherence: needs local ridge flow consistency across patches
# continuity: needs to detect ridge break locations spatially
# minutiae_reliability: needs to localise bifurcation / ending regions
#
# BREAKING CHANGE: incompatible with v16–v26 checkpoints.
#
# All other hyperparameters identical to v26 (gamma=2.0, spread-weight=3.0).
# After confirming spatial head matches or exceeds v26 on KS/Pearson, the
# noise→noise_lv supervision mismatch (+0.365 in v24/v26) can be addressed.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
export PATH="/home/aiserver/miniconda3/bin:$PATH"
VERSION="v27"
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 2.0 \
--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
|