fairtalking-second-work / scripts /run_all_ablations.sh
huahua123313's picture
Add files using upload-large-folder tool
7c2871f verified
Raw
History Blame Contribute Delete
3.55 kB
#!/usr/bin/env bash
# Run ALL CTA ablation variants sequentially (or in parallel with GNU parallel).
#
# Usage:
# # Sequential (safe, one GPU job at a time):
# bash scripts/run_all_ablations.sh
#
# # Parallel (if you have enough GPUs, e.g. 8 variants × 8 GPUs each):
# bash scripts/run_all_ablations.sh --parallel
#
# # Run only a specific group (A / B / C / D / E / F / G / M):
# bash scripts/run_all_ablations.sh --group A
# bash scripts/run_all_ablations.sh --group B
# bash scripts/run_all_ablations.sh --group M # modality / cross-modal role
#
# Each variant writes to:
# outputs/cta_ablation_<VARIANT>_<timestamp>/
#
# After all runs finish, use scripts/collect_ablation_results.sh to
# aggregate test AUC numbers into a single CSV.
set -euo pipefail
cd "$(dirname "$0")/.."
[ -f .env ] && set -a && . ./.env && set +a
# ---- parse args ------------------------------------------------------------
PARALLEL=false
GROUP=""
while [[ $# -gt 0 ]]; do
case "$1" in
--parallel) PARALLEL=true; shift ;;
--group) GROUP="$2"; shift 2 ;;
*) echo "Unknown arg: $1"; exit 1 ;;
esac
done
# ---- define all variants ---------------------------------------------------
declare -A GROUP_VARIANTS
GROUP_VARIANTS[A]="A1_full A2_no_asym A3_no_ltotal A4_asym_only A5_pooled_only"
GROUP_VARIANTS[B]="B1_real_only B2_all_samples B3_no_predictor"
GROUP_VARIANTS[C]="C1_no_loss_asym C2_no_loss_aux C3_no_loss_av C4_no_loss_va C5_no_detach"
GROUP_VARIANTS[D]="D1_depth_1 D2_depth_4 D3_depth_8 D4_mlp_predictor D5_shared_predictor"
GROUP_VARIANTS[E]="E1_video_freeze_0 E2_video_freeze_07 E3_video_freeze_10"
GROUP_VARIANTS[F]="F1_audio_freeze_0 F2_audio_freeze_08"
GROUP_VARIANTS[G]="G2_random_crop"
GROUP_VARIANTS[M]="M1_video_only M2_audio_only M3_intra_modal M4_noise_target M5_shuffle_pair M6_drop_audio_infer M7_drop_video_infer"
# Build the list of variants to run
if [[ -n "$GROUP" ]]; then
if [[ -z "${GROUP_VARIANTS[$GROUP]+_}" ]]; then
echo "[ablation] Unknown group: $GROUP. Valid groups: A B C D E F G M"
exit 1
fi
VARIANTS="${GROUP_VARIANTS[$GROUP]}"
else
VARIANTS=""
for g in A B C D E F G M; do
VARIANTS="$VARIANTS ${GROUP_VARIANTS[$g]}"
done
fi
echo "============================================================"
echo "[ablation] Variants to run:"
for v in $VARIANTS; do echo " - $v"; done
echo "============================================================"
# ---- run -------------------------------------------------------------------
run_variant() {
local variant="$1"
echo ""
echo "============================================================"
echo "[ablation] START: $variant ($(date '+%Y-%m-%d %H:%M:%S'))"
echo "============================================================"
bash scripts/train_cta_ablation.sh "$variant"
echo "[ablation] DONE: $variant ($(date '+%Y-%m-%d %H:%M:%S'))"
}
export -f run_variant
if $PARALLEL; then
# Requires GNU parallel: sudo apt-get install parallel
echo "[ablation] Running in PARALLEL mode (requires GNU parallel)"
echo "$VARIANTS" | tr ' ' '\n' | grep -v '^$' | \
parallel --jobs 4 --line-buffer run_variant {}
else
for variant in $VARIANTS; do
run_variant "$variant"
done
fi
echo ""
echo "============================================================"
echo "[ablation] All variants finished. Run collect_ablation_results.sh"
echo " to aggregate results."
echo "============================================================"